forked from tektoncd/pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ignore-step-error.yaml
49 lines (49 loc) · 1.67 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
kind: TaskRun
apiVersion: tekton.dev/v1
metadata:
generateName: taskrun-with-failing-step-
spec:
taskSpec:
steps:
# exit with 1 and ignore non zero exit code
- image: alpine
onError: continue
name: exit-with-1
script: |
exit 1
# check if the /tekton/steps/step-<step-name>/exitCode got created and contains the exit code
# check if the symlink /tekton/steps/0/ got created
- image: alpine
name: verify-step-path
script: |
exitCode=`cat $(steps.step-exit-with-1.exitCode.path)`
if [ $exitCode == 1 ]; then
echo "Yay! the exit code can be accessed using the path variable and matches the previous step exit code"
else
echo "the exit code does not match."
exit 1
fi
FILE=/tekton/steps/step-exit-with-1/exitCode
if [ -f "$FILE" ]; then
echo "$FILE exists."
echo "Yay! the file exists which was created by the controller to record the step exit code."
else
echo "$FILE does not exist."
exit 1
fi
FILE=/tekton/steps/0/exitCode
if [ -f "$FILE" ]; then
echo "$FILE exists."
echo "Yay! the symlink exists which was created by the controller to record the step exit code."
else
echo "$FILE does not exist."
exit 1
fi
exitCode=`cat $FILE`
if [ $exitCode == 1 ]; then
echo "Yay! the exit code matches to the previous step exit code"
else
echo "the exit code does not match."
exit 1
fi
---