Skip to content

Commit badc734

Browse files
authored
Fix no repeated subjects for v2alpha4 pipelineruns (#1130)
Change the pipelinerun v2alpha4 method that calculates the subjects to use `artifact.AppendSubjects` instead of `append` to avoid duplicated subjects.
1 parent bf7a3c9 commit badc734

File tree

8 files changed

+1056
-16
lines changed

8 files changed

+1056
-16
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
apiVersion: tekton.dev/v1
2+
kind: PipelineRun
3+
metadata:
4+
name: pipeline-test-run
5+
spec:
6+
pipelineSpec:
7+
results:
8+
- name: output1-ARTIFACT_OUTPUTS
9+
value: $(tasks.t1.results.output1-ARTIFACT_OUTPUTS)
10+
- name: output2-ARTIFACT_OUTPUTS
11+
value: $(tasks.t1.results.output2)
12+
- name: output3-ARTIFACT_OUTPUTS
13+
value: $(tasks.t2.results.output3-ARTIFACT_OUTPUTS)
14+
tasks:
15+
- name: t1
16+
taskSpec:
17+
results:
18+
- name: output1-ARTIFACT_OUTPUTS
19+
type: object
20+
properties:
21+
uri: {}
22+
digest: {}
23+
isBuildArtifact: {}
24+
25+
- name: output2
26+
type: object
27+
properties:
28+
uri: {}
29+
digest: {}
30+
31+
steps:
32+
- name: step1
33+
image: busybox:glibc
34+
script: |
35+
echo -n "Hello!"
36+
echo -n "{\"uri\":\"gcr.io/foo/img1\", \"digest\":\"sha256:586789aa031fafc7d78a5393cdc772e0b55107ea54bb8bcf3f2cdac6c6da51ee\", \"isBuildArtifact\": \"true\" }" > $(results.output1-ARTIFACT_OUTPUTS.path)
37+
echo -n "{\"uri\":\"gcr.io/foo/img2\", \"digest\":\"sha256:586789aa031fafc7d78a5393cdc772e0b55107ea54bb8bcf3f2cdac6c6da51ee\"}" > $(results.output2.path)
38+
39+
- name: t2
40+
taskSpec:
41+
results:
42+
- name: output3-ARTIFACT_OUTPUTS
43+
type: object
44+
properties:
45+
uri: {}
46+
digest: {}
47+
isBuildArtifact: {}
48+
steps:
49+
- name: step1
50+
image: busybox:glibc
51+
script: |
52+
echo -n "Hello!"
53+
echo -n "{\"uri\":\"gcr.io/foo/img1\", \"digest\":\"sha256:586789aa031fafc7d78a5393cdc772e0b55107ea54bb8bcf3f2cdac6c6da51ee\", \"isBuildArtifact\": \"true\" }" > $(results.output3-ARTIFACT_OUTPUTS.path)
54+
55+
- name: t3
56+
taskSpec:
57+
results:
58+
- name: IMAGES
59+
type: string
60+
steps:
61+
- name: step1
62+
image: busybox:glibc
63+
script: |
64+
echo -n "gcr.io/foo/img1@sha256:586789aa031fafc7d78a5393cdc772e0b55107ea54bb8bcf3f2cdac6c6da51ee" > $(results.IMAGES.path)
Lines changed: 328 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,328 @@
1+
{
2+
"metadata": {
3+
"name": "pipelinerun-build",
4+
"uid": "abhhf-12354-asjsdbjs23-3435353n"
5+
},
6+
"spec": {
7+
"params": [
8+
{
9+
"name": "IMAGE",
10+
"value": "test.io/test/image"
11+
}
12+
],
13+
"pipelineRef": {
14+
"name": "test-pipeline"
15+
},
16+
"taskRunTemplate": {
17+
"serviceAccountName": "pipeline"
18+
}
19+
},
20+
"status": {
21+
"startTime": "2021-03-29T09:50:00Z",
22+
"completionTime": "2021-03-29T09:50:15Z",
23+
"conditions": [
24+
{
25+
"lastTransitionTime": "2021-03-29T09:50:15Z",
26+
"message": "Tasks Completed: 2 (Failed: 0, Cancelled 0), Skipped: 0",
27+
"reason": "Succeeded",
28+
"status": "True",
29+
"type": "Succeeded"
30+
}
31+
],
32+
"results": [
33+
{
34+
"name": "CHAINS-GIT_COMMIT",
35+
"value": "abcd"
36+
},
37+
{
38+
"name": "CHAINS-GIT_URL",
39+
"value": "https://git.test.com"
40+
},
41+
{
42+
"name": "IMAGE_URL",
43+
"value": "test.io/test/image"
44+
},
45+
{
46+
"name": "IMAGE_DIGEST",
47+
"value": "sha256:827521c857fdcd4374f4da5442fbae2edb01e7fbae285c3ec15673d4c1daecb7"
48+
},
49+
{
50+
"name": "build-artifact-ARTIFACT_OUTPUTS",
51+
"value": {
52+
"uri": "abc",
53+
"digest": "sha256:827521c857fdcd4374f4da5442fbae2edb01e7fbae285c3ec15673d4c1daecb7",
54+
"isBuildArtifact": "true"
55+
}
56+
},
57+
{
58+
"name": "img-ARTIFACT_INPUTS",
59+
"value": {
60+
"uri": "abc","digest": "sha256:827521c857fdcd4374f4da5442fbae2edb01e7fbae285c3ec15673d4c1daecb7"
61+
}
62+
},
63+
{
64+
"name": "img2-ARTIFACT_OUTPUTS",
65+
"value": {
66+
"uri": "def","digest": "sha256:","isBuildArtifact": "true"
67+
}
68+
},
69+
{
70+
"name": "img_no_uri-ARTIFACT_OUTPUTS",
71+
"value": {
72+
"digest": "sha256:827521c857fdcd4374f4da5442fbae2edb01e7fbae285c3ec15673d4c1daecb7"
73+
}
74+
},
75+
{
76+
"name": "common-ARTIFACT_OUTPUTS",
77+
"value": {
78+
"uri": "gcr.io/common/image",
79+
"digest": "sha256:33e7e52645f4859622e282167d9200da9861b3d0a6e9c93b85e9cae5526ffc0a",
80+
"isBuildArtifact": "true"
81+
}
82+
}
83+
],
84+
"pipelineSpec": {
85+
"params": [
86+
{
87+
"description": "Image path on registry",
88+
"name": "IMAGE",
89+
"type": "string"
90+
}
91+
],
92+
"results": [
93+
{
94+
"description": "",
95+
"name": "CHAINS-GIT_COMMIT",
96+
"value": "$(tasks.git-clone.results.commit)"
97+
},
98+
{
99+
"description": "",
100+
"name": "CHAINS-GIT_URL",
101+
"value": "$(tasks.git-clone.results.url)"
102+
},
103+
{
104+
"description": "",
105+
"name": "IMAGE_URL",
106+
"value": "$(tasks.build.results.IMAGE_URL)"
107+
},
108+
{
109+
"description": "",
110+
"name": "IMAGE_DIGEST",
111+
"value": "$(tasks.build.results.IMAGE_DIGEST)"
112+
}
113+
],
114+
"tasks": [
115+
{
116+
"name": "git-clone",
117+
"params": [
118+
{
119+
"name": "url",
120+
"value": "https://git.test.com"
121+
},
122+
{
123+
"name": "revision",
124+
"value": ""
125+
}
126+
],
127+
"taskRef": {
128+
"kind": "ClusterTask",
129+
"name": "git-clone"
130+
}
131+
},
132+
{
133+
"name": "build",
134+
"params": [
135+
{
136+
"name": "CHAINS-GIT_COMMIT",
137+
"value": "$(tasks.git-clone.results.commit)"
138+
},
139+
{
140+
"name": "CHAINS-GIT_URL",
141+
"value": "$(tasks.git-clone.results.url)"
142+
}
143+
],
144+
"taskRef": {
145+
"kind": "ClusterTask",
146+
"name": "build"
147+
}
148+
}
149+
]
150+
},
151+
"taskRuns": {
152+
"git-clone": {
153+
"pipelineTaskName": "git-clone",
154+
"status": {
155+
"completionTime": "2021-03-29T09:50:15Z",
156+
"conditions": [
157+
{
158+
"lastTransitionTime": "2021-03-29T09:50:15Z",
159+
"message": "All Steps have completed executing",
160+
"reason": "Succeeded",
161+
"status": "True",
162+
"type": "Succeeded"
163+
}
164+
],
165+
"podName": "git-clone-pod",
166+
"startTime": "2021-03-29T09:50:00Z",
167+
"steps": [
168+
{
169+
"container": "step-clone",
170+
"imageID": "test.io/test/clone-image",
171+
"name": "clone",
172+
"terminated": {
173+
"exitCode": 0,
174+
"finishedAt": "2021-03-29T09:50:15Z",
175+
"reason": "Completed",
176+
"startedAt": "2022-05-31T19:13:27Z"
177+
}
178+
}
179+
],
180+
"results": [
181+
{
182+
"name": "commit",
183+
"value": "abcd"
184+
},
185+
{
186+
"name": "url",
187+
"value": "https://git.test.com"
188+
}
189+
],
190+
"taskSpec": {
191+
"params": [
192+
{
193+
"description": "Repository URL to clone from.",
194+
"name": "url",
195+
"type": "string"
196+
},
197+
{
198+
"default": "",
199+
"description": "Revision to checkout. (branch, tag, sha, ref, etc...)",
200+
"name": "revision",
201+
"type": "string"
202+
}
203+
],
204+
"results": [
205+
{
206+
"description": "The precise commit SHA that was fetched by this Task.",
207+
"name": "commit"
208+
},
209+
{
210+
"description": "The precise URL that was fetched by this Task.",
211+
"name": "url"
212+
}
213+
],
214+
"steps": [
215+
{
216+
"env": [
217+
{
218+
"name": "HOME",
219+
"value": "$(params.userHome)"
220+
},
221+
{
222+
"name": "PARAM_URL",
223+
"value": "$(params.url)"
224+
}
225+
],
226+
"image": "$(params.gitInitImage)",
227+
"name": "clone",
228+
"resources": {},
229+
"script": "git clone"
230+
}
231+
]
232+
}
233+
}
234+
},
235+
"taskrun-build": {
236+
"pipelineTaskName": "build",
237+
"status": {
238+
"completionTime": "2021-03-29T09:50:15Z",
239+
"conditions": [
240+
{
241+
"lastTransitionTime": "2021-03-29T09:50:15Z",
242+
"message": "All Steps have completed executing",
243+
"reason": "Succeeded",
244+
"status": "True",
245+
"type": "Succeeded"
246+
}
247+
],
248+
"podName": "build-pod",
249+
"startTime": "2021-03-29T09:50:00Z",
250+
"steps": [
251+
{
252+
"container": "step-build",
253+
"imageID": "test.io/test/build-image",
254+
"name": "build",
255+
"terminated": {
256+
"exitCode": 0,
257+
"finishedAt": "2022-05-31T19:17:30Z",
258+
"reason": "Completed",
259+
"startedAt": "2021-03-29T09:50:00Z"
260+
}
261+
}
262+
],
263+
"results": [
264+
{
265+
"name": "IMAGE_DIGEST",
266+
"value": "sha256:827521c857fdcd4374f4da5442fbae2edb01e7fbae285c3ec15673d4c1daecb7"
267+
},
268+
{
269+
"name": "IMAGE_URL",
270+
"value": "test.io/test/image\n"
271+
}
272+
],
273+
"taskSpec": {
274+
"params": [
275+
{
276+
"description": "Git CHAINS URL",
277+
"name": "CHAINS-GIT_URL",
278+
"type": "string"
279+
},
280+
{
281+
"description": "Git CHAINS Commit",
282+
"name": "CHAINS-GIT_COMMIT",
283+
"type": "string"
284+
}
285+
],
286+
"results": [
287+
{
288+
"description": "Digest of the image just built.",
289+
"name": "IMAGE_DIGEST"
290+
},
291+
{
292+
"description": "URL of the image just built.",
293+
"name": "IMAGE_URL"
294+
}
295+
],
296+
"steps": [
297+
{
298+
"command": [
299+
"buildah",
300+
"build"
301+
],
302+
"image": "test.io/test/build-image",
303+
"name": "generate"
304+
},
305+
{
306+
"command": [
307+
"buildah",
308+
"push"
309+
],
310+
"image": "test.io/test/build-image",
311+
"name": "push"
312+
}
313+
]
314+
}
315+
}
316+
}
317+
},
318+
"provenance": {
319+
"refSource": {
320+
"uri": "git+https://github.com/test",
321+
"digest": {
322+
"sha1": "28b123"
323+
},
324+
"entryPoint": "pipeline.yaml"
325+
}
326+
}
327+
}
328+
}

0 commit comments

Comments
 (0)