forked from tektoncd/pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ignore-step-error.yaml
120 lines (119 loc) · 3.37 KB
/
ignore-step-error.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
111
112
113
114
115
116
117
118
119
120
kind: PipelineRun
apiVersion: tekton.dev/v1
metadata:
generateName: pipelinerun-with-failing-step-
spec:
taskRunTemplate:
serviceAccountName: 'default'
params:
- name: CONTINUE
value: "continue"
pipelineSpec:
params:
- name: CONTINUE
tasks:
- name: task1
params:
- name: CONTINUE
value: "$(params.CONTINUE)"
taskSpec:
params:
- name: CONTINUE
steps:
# not really doing anything here, just a hurdle to test the "ignore step error"
- image: alpine
onError: $(params.CONTINUE)
name: exit-with-1
script: |
exit 1
# initialize a task result which will be validated by the next task
- image: alpine
name: write-a-result
onError: continue
script: |
echo -n 123 | tee $(results.task1-result.path)
exit 11
results:
- name: task1-result
description: result of a task1
- name: task2
runAfter: ["task1"]
params:
- name: task1-result
value: $(tasks.task1.results.task1-result)
taskSpec:
params:
- name: task1-result
steps:
# again, not really doing anything here, just a hurdle to test the "ignore step error"
- image: alpine
onError: continue
name: exit-with-255
script: |
exit 255
# verify that the task result was produced by the first task, fail if the result does not match
- image: alpine
name: verify-a-task-result
script: |
if [ $(params.task1-result) == 123 ]; then
echo "Yay! the task result matches which was initialized in the previous task while ignoring the step error"
else
echo "the task result does not match."
exit 1
fi
# the last step of a task and one more hurdle
- image: alpine
name: exit-with-20
onError: continue
script: |
exit 20
---
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
generateName: pipelinerun-with-failing-step-and-ws-
spec:
workspaces:
- name: ws
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 16Mi
pipelineSpec:
tasks:
- name: writer
taskSpec:
steps:
- name: write
image: alpine
onError: continue
script: |
ls -1 /tekton/run/
echo bar > $(workspaces.task-ws.path)/foo
exit 1
workspaces:
- name: task-ws
workspaces:
- name: task-ws
workspace: ws
- name: reader
runAfter:
- writer
taskSpec:
steps:
- name: read
image: alpine
onError: continue
script: |
cat $(workspaces.myws.path)/foo | grep bar
exit 1
workspaces:
- name: myws
workspaces:
- name: myws
workspace: ws
workspaces:
- name: ws