forked from tektoncd/pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconditional-pipelinerun-with-optional-resources.yaml
87 lines (87 loc) · 2.2 KB
/
conditional-pipelinerun-with-optional-resources.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
# `Conditions` are deprecated, use `WhenExpressions` instead
# https://github.com/tektoncd/pipeline/blob/master/docs/pipelines.md#guard-task-execution-using-whenexpressions
apiVersion: tekton.dev/v1alpha1
kind: Condition
metadata:
name: verify-no-file-exists-without-resource
spec:
params:
- name: "path"
resources:
- name: optional-workspace
type: git
optional: true
check:
image: alpine
script: 'test ! -f $(resources.optional-workspace.path)/$(params.path)'
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: pipeline-git-repo
spec:
type: git
params:
- name: revision
value: master
- name: url
value: https://github.com/tektoncd/pipeline
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: list-pipeline-repo-files
spec:
resources:
inputs:
- name: optional-workspace
type: git
optional: true
steps:
- name: run-ls
image: ubuntu
script: 'ls -al $(inputs.resources.optional-workspace.path)'
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: pipeline-list-pipeline-repo-files
spec:
resources:
- name: pipeline-source-repo
type: git
params:
- name: "path"
default: "README.md"
tasks:
- name: list-pipeline-repo-files-1
taskRef:
name: list-pipeline-repo-files
conditions:
- conditionRef: "verify-no-file-exists-without-resource"
params:
- name: "path"
value: "$(params.path)"
# NOTE: Resource "optional-workspace" is declared as optional in Condition
# No resource specified for the condition here since its optional
# "DO NOT UNCOMMENT THE FOLLOWING RESOURCE"
# resources:
# - name: optional-workspace
# resource: pipeline-source-repo
resources:
inputs:
- name: optional-workspace
resource: pipeline-source-repo
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: demo-conditional-pr-without-condition-resource
spec:
pipelineRef:
name: pipeline-list-pipeline-repo-files
serviceAccountName: 'default'
resources:
- name: pipeline-source-repo
resourceRef:
name: pipeline-git-repo