-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
pipelinerun-with-matrix-emitting-results.yaml
110 lines (110 loc) · 2.95 KB
/
pipelinerun-with-matrix-emitting-results.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: echostringurl
spec:
params:
- name: url
type: string
steps:
- name: echo
image: mirror.gcr.io/alpine
script: |
echo "$(params.url)"
---
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: validate-array-url
spec:
params:
- name: url
type: array
steps:
- name: validate
image: mirror.gcr.io/ubuntu
args: ["$(params.url[*])"]
script: |
#!/usr/bin/env bash
args=("$@")
URLS=( )
URLS[0]="https://api.example/get-report/linux-chrome"
URLS[1]="https://api.example/get-report/mac-chrome"
URLS[2]="https://api.example/get-report/windows-chrome"
URLS[3]="https://api.example/get-report/linux-safari"
URLS[4]="https://api.example/get-report/mac-safari"
URLS[5]="https://api.example/get-report/windows-safari"
URLS[6]="https://api.example/get-report/linux-firefox"
URLS[7]="https://api.example/get-report/mac-firefox"
URLS[8]="https://api.example/get-report/windows-firefox"
for i in "${!URLS[@]}"; do
if [ "${URLS[$i]}" != ${args[$i]} ]; then
echo "Error: expected url to be ${URLS[$i]}, but got ${args[$i]}"
exit 1
fi
echo "Done validating the url: ${args[$i]}"
done
---
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: task-producing-results
spec:
params:
- name: platform
default: ""
- name: browser
default: ""
results:
- name: report-url
type: string
steps:
- name: produce-report-url
image: mirror.gcr.io/alpine
script: |
echo "Running tests on $(params.platform)-$(params.browser)"
echo -n "https://api.example/get-report/$(params.platform)-$(params.browser)" | tee $(results.report-url.path)
---
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
generateName: platforms-with-results
spec:
taskRunTemplate:
serviceAccountName: "default"
pipelineSpec:
results:
- name: pr-result-1
value: $(tasks.matrix-emitting-results.results.report-url[*])
tasks:
- name: matrix-emitting-results
matrix:
params:
- name: platform
value:
- linux
- mac
- windows
- name: browser
value:
- chrome
- safari
- firefox
taskRef:
name: task-producing-results
kind: Task
- name: task-consuming-results
taskRef:
name: validate-array-url
kind: Task
params:
- name: url
value: $(tasks.matrix-emitting-results.results.report-url[*])
- name: matrix-consuming-results
taskRef:
name: echostringurl
kind: Task
matrix:
params:
- name: url
value: $(tasks.matrix-emitting-results.results.report-url[*])