-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding `WhenExpressions` used to efficiently specify guarded execution of `Tasks`, without spinning up new pods. We use `WhenExpressions` to avoid adding an opinionated and complex expression language to the Tekton API to ensure Tekton can be supported by as many systems as possible. Further details about the design are in [Conditions Beta TEP](https://github.com/tektoncd/community/blob/master/teps/0007-conditions-beta.md). The components of `WhenExpressions` are `Input`, `Operator` and `Values`: - `Input` is the input for the `Guard` checking which can be static inputs or variables, such as `Parameters` or `Results`. - `Operator` represents an `Input`'s relationship to a set of `Values`. `Operators` we will use in `WhenExpressions` are `In` and `NotIn`. - `Values` is an array of string values. The `Values` array must be non-empty. It can contain static values or variables (`Parameters` or `Results`). The declared `WhenExpressions` are evaluated before the `Task` is run. If all the `WhenExpressions` evaluate to `True`, the `Task` is run. If any of the `WhenExpressions` evaluate to `False`, the `Task` is skipped. When a `Task` is skipped, it's included in the `Skipped Tasks` section of the `PipelineRunStatus`.
- Loading branch information
1 parent
bf4d14d
commit 079a6c8
Showing
30 changed files
with
2,023 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
examples/v1beta1/pipelineruns/conditional-pipelinerun-with-optional-resources.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
examples/v1beta1/pipelineruns/conditional-pipelinerun-with-same-condition-refer.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
examples/v1beta1/pipelineruns/pipeline-result-conditions.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
examples/v1beta1/pipelineruns/pipelinerun-with-when-expressions.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Pipeline | ||
metadata: | ||
name: guarded-pipeline | ||
spec: | ||
params: | ||
- name: path | ||
type: string | ||
description: The path of the file to be created | ||
workspaces: | ||
- name: source | ||
description: | | ||
This workspace will receive the cloned git repo and be passed | ||
to the next Task to create a file | ||
tasks: | ||
- name: create-file | ||
when: | ||
- input: "$(params.path)" | ||
operator: in | ||
values: ["README.md"] | ||
workspaces: | ||
- name: source | ||
workspace: source | ||
taskSpec: | ||
workspaces: | ||
- name: source | ||
description: The workspace to create the readme file in | ||
steps: | ||
- name: write-new-stuff | ||
image: ubuntu | ||
script: 'touch $(workspaces.source.path)/README.md' | ||
- name: check-file | ||
params: | ||
- name: path | ||
value: "$(params.path)" | ||
workspaces: | ||
- name: source | ||
workspace: source | ||
runAfter: | ||
- create-file | ||
taskSpec: | ||
params: | ||
- name: path | ||
workspaces: | ||
- name: source | ||
description: The workspace to check for the file | ||
results: | ||
- name: status | ||
description: indicates whether the file exists or is missing | ||
steps: | ||
- name: check-file | ||
image: alpine | ||
script: | | ||
if test -f $(workspaces.source.path)/$(params.path); then | ||
printf exists | tee /tekton/results/status | ||
else | ||
printf missing | tee /tekton/results/status | ||
fi | ||
- name: echo-file-exists | ||
when: | ||
- input: "$(tasks.check-file.results.status)" | ||
operator: in | ||
values: ["exists"] | ||
taskSpec: | ||
steps: | ||
- name: echo | ||
image: ubuntu | ||
script: 'echo file exists' | ||
- name: task-should-be-skipped | ||
when: | ||
- input: "$(params.path)" | ||
operator: notin | ||
values: ["README.md"] | ||
taskSpec: | ||
steps: | ||
- name: echo | ||
image: ubuntu | ||
script: exit 1 | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: PipelineRun | ||
metadata: | ||
name: guarded-pr | ||
spec: | ||
serviceAccountName: 'default' | ||
pipelineRef: | ||
name: guarded-pipeline | ||
params: | ||
- name: path | ||
value: README.md | ||
workspaces: | ||
- name: source | ||
volumeClaimTemplate: | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 1Gi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.