1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/mirrors-Tekton

Клонировать/Скачать
pipelinerun-with-when-expressions.yaml 6.6 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
Chitrang Patel Отправлено 22.07.2024 22:01 a9b204e
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
generateName: guarded-pr-
spec:
taskRunTemplate:
serviceAccountName: 'default'
pipelineSpec:
params:
- name: path
type: string
description: The path of the file to be created
- name: branches
type: array
description: The list of branch names
workspaces:
- name: source
description: |
This workspace is shared among all the pipeline tasks to read/write common resources
tasks:
- name: create-file # when expression using parameter, evaluates to true
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: mirror.gcr.io/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: exists
description: indicates whether the file exists or is missing
steps:
- name: check-file
image: mirror.gcr.io/alpine
script: |
if test -f $(workspaces.source.path)/$(params.path); then
printf yes | tee $(results.exists.path)
else
printf no | tee $(results.exists.path)
fi
- name: echo-file-exists # when expression using task result, evaluates to true
when:
- input: "$(tasks.check-file.results.exists)"
operator: in
values: ["yes"]
taskSpec:
steps:
- name: echo
image: mirror.gcr.io/ubuntu
script: 'echo file exists'
- name: sample-task-with-array-values
when:
- input: "main"
operator: in
values: ["$(params.branches[*])"]
taskSpec:
steps:
- name: echo
image: mirror.gcr.io/alpine
script: 'echo hello'
- name: task-should-be-skipped-1
when:
- input: "$(tasks.check-file.results.exists)" # when expression using task result, evaluates to false
operator: in
values: ["missing"]
taskSpec:
steps:
- name: echo
image: mirror.gcr.io/ubuntu
script: exit 1
- name: task-should-be-skipped-2 # when expression using parameter, evaluates to false
when:
- input: "$(params.path)"
operator: notin
values: ["README.md"]
taskSpec:
steps:
- name: echo
image: mirror.gcr.io/ubuntu
script: exit 1
- name: task-should-be-skipped-3 # task with when expression and run after
runAfter:
- echo-file-exists
when:
- input: "monday"
operator: in
values: ["friday"]
taskSpec:
steps:
- name: echo
image: mirror.gcr.io/ubuntu
script: exit 1
- name: task-should-be-skipped-4 # task with when expression using array parameter, evaluates to false
when:
- input: "master"
operator: in
values: ["$(params.branches[*])"]
taskSpec:
steps:
- name: echo
image: mirror.gcr.io/alpine
script: exit 1
finally:
- name: finally-task-should-be-skipped-1 # when expression using execution status, evaluates to false
when:
- input: "$(tasks.echo-file-exists.status)"
operator: in
values: ["Failure"]
taskSpec:
steps:
- name: echo
image: mirror.gcr.io/ubuntu
script: exit 1
- name: finally-task-should-be-skipped-2 # when expression using task result, evaluates to false
when:
- input: "$(tasks.check-file.results.exists)"
operator: in
values: ["missing"]
taskSpec:
steps:
- name: echo
image: mirror.gcr.io/ubuntu
script: exit 1
- name: finally-task-should-be-skipped-3 # when expression using parameter, evaluates to false
when:
- input: "$(params.path)"
operator: notin
values: ["README.md"]
taskSpec:
steps:
- name: echo
image: mirror.gcr.io/ubuntu
script: exit 1
- name: finally-task-should-be-skipped-4 # when expression using tasks execution status, evaluates to false
when:
- input: "$(tasks.status)"
operator: in
values: ["Failure"]
taskSpec:
steps:
- name: echo
image: mirror.gcr.io/ubuntu
script: exit 1
- name: finally-task-should-be-skipped-5 # when expression using tasks execution status, evaluates to false
when:
- input: "$(tasks.status)"
operator: in
values: ["Succeeded"]
taskSpec:
steps:
- name: echo
image: mirror.gcr.io/ubuntu
script: exit 1
- name: finally-task-should-be-executed # when expression using execution status, tasks execution status, param, and results
when:
- input: "$(tasks.echo-file-exists.status)"
operator: in
values: ["Succeeded"]
- input: "$(tasks.status)"
operator: in
values: ["Completed"]
- input: "$(tasks.check-file.results.exists)"
operator: in
values: ["yes"]
- input: "$(params.path)"
operator: in
values: ["README.md"]
taskSpec:
steps:
- name: echo
image: mirror.gcr.io/ubuntu
script: 'echo finally done'
params:
- name: path
value: README.md
- name: branches
value:
- main
- hotfix
workspaces:
- name: source
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 16Mi

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/mirrors-Tekton.git
git@api.gitlife.ru:oschina-mirror/mirrors-Tekton.git
oschina-mirror
mirrors-Tekton
mirrors-Tekton
main