|
25 | 25 | - description: Source Repository URL |
26 | 26 | name: git-url |
27 | 27 | type: string |
| 28 | + - default: "" |
| 29 | + description: Upstream source Repository URL |
| 30 | + name: upstream-git-url |
| 31 | + type: string |
28 | 32 | - default: "" |
29 | 33 | description: Revision of the Source Repository |
30 | 34 | name: revision |
|
33 | 37 | name: output-image |
34 | 38 | type: string |
35 | 39 | - default: . |
36 | | - description: Path to the source code of an application's component from where |
| 40 | + description: Path to the source code of an applications component from where |
37 | 41 | to build image. |
38 | 42 | name: path-context |
39 | 43 | type: string |
@@ -142,6 +146,35 @@ spec: |
142 | 146 | workspaces: |
143 | 147 | - name: basic-auth |
144 | 148 | workspace: git-auth |
| 149 | + - name: extract-upstream-info |
| 150 | + taskSpec: |
| 151 | + results: |
| 152 | + - name: upstream-vcs-ref |
| 153 | + steps: |
| 154 | + - name: use-trusted-artifact |
| 155 | + image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:8391272c4e5011120e9e7fee2c1f339e9405366110bf239dadcbc21e953ce099 |
| 156 | + args: |
| 157 | + - use |
| 158 | + - $(tasks.clone-repository.results.SOURCE_ARTIFACT)=/var/workdir/source |
| 159 | + - image: registry.access.redhat.com/ubi9/ubi |
| 160 | + workingDir: /var/workdir/source |
| 161 | + script: | |
| 162 | + #!/usr/bin/env bash |
| 163 | + echo -n $(cat head 2>/dev/null || echo -n "") | tee $(results.upstream-vcs-ref.path) |
| 164 | + stepTemplate: |
| 165 | + volumeMounts: |
| 166 | + - mountPath: /var/workdir |
| 167 | + name: workdir |
| 168 | + volumes: |
| 169 | + - name: workdir |
| 170 | + emptyDir: {} |
| 171 | + runAfter: |
| 172 | + - clone-repository |
| 173 | + when: |
| 174 | + - input: $(tasks.init.results.build) |
| 175 | + operator: in |
| 176 | + values: |
| 177 | + - "true" |
145 | 178 | - name: prefetch-dependencies |
146 | 179 | params: |
147 | 180 | - name: input |
@@ -209,8 +242,18 @@ spec: |
209 | 242 | value: $(tasks.prefetch-dependencies.results.CACHI2_ARTIFACT) |
210 | 243 | - name: IMAGE_APPEND_PLATFORM |
211 | 244 | value: $(params.build-image-index) |
| 245 | + - name: LABELS |
| 246 | + # Labels to mimic several s2i openshift labels as well as include upstream info |
| 247 | + # See also: https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/builds_using_buildconfig/managing-build-output#builds-output-image-labels_managing-build-output |
| 248 | + value: |
| 249 | + - "io.openshift.build.commit.id=$(tasks.clone-repository.results.commit)" |
| 250 | + - "io.openshift.build.commit.url=$(params.git-url)/commit/$(tasks.clone-repository.results.commit)" |
| 251 | + - "io.openshift.build.source-location=$(params.git-url)" |
| 252 | + - "upstream-vcs-ref=$(tasks.extract-upstream-info.results.upstream-vcs-ref)" |
| 253 | + - "upstream-vcs-location=$(params.upstream-git-url)" |
212 | 254 | runAfter: |
213 | 255 | - prefetch-dependencies |
| 256 | + - extract-upstream-info |
214 | 257 | taskRef: |
215 | 258 | params: |
216 | 259 | - name: name |
|
0 commit comments