티스토리 뷰
아래 소스를 test-condition.yaml로 저장하십시오.
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: pipeline-git
spec:
type: git
params:
- name: revision
value: master
- name: url
value: https://github.com/tektoncd/pipeline
---
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: list-files
spec:
inputs:
resources:
- name: workspace
type: git
steps:
- name: run-ls
image: ubuntu
command:
- /bin/bash
args:
- -c
- ls -al $(inputs.resources.workspace.path)
---
apiVersion: tekton.dev/v1alpha1
kind: Condition
metadata:
name: file-exists
spec:
check:
image: alpine
command:
- /bin/sh
args:
- -c
- test -f $(resources.workspace.path)/$(params.path)
params:
- name: path
resources:
- name: workspace
type: git
---
apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
name: list-files-pipeline
spec:
params:
- default: README.md
name: path
type: string
resources:
- name: source-repo
type: git
tasks:
- name: list-files-1
taskRef:
name: list-files
resources:
inputs:
- name: workspace
resource: source-repo
conditions:
- conditionRef: file-exists
params:
- name: path
value: $(params.path)
resources:
- name: workspace
resource: source-repo
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineRun
metadata:
name: demo-condtional-pr
spec:
serviceAccountName: default
pipelineRef:
name: list-files-pipeline
resources:
- name: source-repo
resourceRef:
name: pipeline-git
pipeline에서 넘기는 README.md파일이 있는지 condition에서 검사하여 그 결과에 따라 Task를 실행하거나 하지 않습니다.
실행해 봅시다.
$ kubectl apply -f test-condition.yaml
$ watch tkn pr list
$ tkn pr logs demo-condtional-pr
위와 비슷하게 파일 list가 표시될겁니다.
자 이번엔 task가 실행안되도록, pipeline의 README.md를 README2.md로 바꾸고 다시 실행해 봅시다.
$ tkn pr delete demo-condtional-pr
$ kubectl apply -f test-condition.yaml
$ watch tkn pr list
$ tkn pr logs demo-condtional-pr
이젠 task가 실행되지 않아 위와 같은 로그가 나올것입니다.
'Agile&DevOps > Tekton' 카테고리의 다른 글
7. Tekton trigger (0) | 2019.12.16 |
---|---|
5. Pipeline Resource (0) | 2019.12.13 |
4. Pipeline & PipelineRun (0) | 2019.12.13 |
3. Task & TaskRun (0) | 2019.12.13 |
2. Tekton 설치하기 (0) | 2019.12.13 |
댓글
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 스포티파이
- 애자일
- 마이크로서비스 패턴
- 디토소비
- 돌봄경제
- 도파밍
- 분초사회
- CQRS
- 요즘남편 없던아빠
- API Composition
- SAGA
- spotify
- 마이크로서비스
- 버라이어티가격
- 호모프롬프트
- 리퀴드폴리탄
- AXON
- micro service
- agile
- 육각형인간
- 스핀프로젝트
- Event Sourcing
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함