-
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.
pipeline level finally - implementation
We can now specify a list of tasks needs to be executed just before pipeline exits (either after finishing all non-final tasks successfully or after a single failure) Most useful for tasks such as report test results, cleanup cluster resources, etc ``` apiVersion: tekton.dev/v1beta1 kind: Pipeline metadata: name: pipeline-with-final-tasks spec: tasks: - name: pre-work taskRef: Name: some-pre-work - name: unit-test taskRef: Name: run-unit-test runAfter: - pre-work - name: integration-test taskRef: Name: run-integration-test runAfter: - unit-test finally: - name: cleanup-test taskRef: Name: cleanup-cluster - name: report-results taskRef: Name: report-test-results ```
- Loading branch information
1 parent
1805671
commit afaa4ac
Showing
10 changed files
with
1,415 additions
and
10 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
95 changes: 95 additions & 0 deletions
95
examples/v1beta1/pipelineruns/pipelinerun-with-final-tasks.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,95 @@ | ||
# Task to clone repo into shared workspace | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: clone-app-repo-to-workspace | ||
spec: | ||
workspaces: | ||
- name: shared-workspace | ||
resources: | ||
inputs: | ||
- name: app-git | ||
type: git | ||
targetPath: application | ||
steps: | ||
- name: clone-app-repo-to-workspace | ||
image: ubuntu | ||
script: | | ||
#!/usr/bin/env bash | ||
set -xe | ||
cp -avr $(resources.inputs.app-git.path)/ $(workspaces.shared-workspace.path)/ | ||
--- | ||
|
||
# Task to cleanup shared workspace | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: cleanup-workspace | ||
spec: | ||
workspaces: | ||
- name: shared-workspace | ||
steps: | ||
- name: cleanup-workspace | ||
image: ubuntu | ||
script: | | ||
#!/usr/bin/env bash | ||
set -xe | ||
rm -rf $(workspaces.shared-workspace.path)/application/ | ||
--- | ||
|
||
# Pipeline to clone repo into shared workspace and cleanup the workspace after done | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Pipeline | ||
metadata: | ||
name: clone-into-workspace-and-cleanup-workspace | ||
spec: | ||
resources: | ||
- name: app-git | ||
type: git | ||
workspaces: | ||
- name: shared-workspace | ||
tasks: | ||
- name: clone-app-source | ||
taskRef: | ||
name: clone-app-repo-to-workspace | ||
workspaces: | ||
- name: shared-workspace | ||
workspace: shared-workspace | ||
resources: | ||
inputs: | ||
- name: app-git | ||
resource: app-git | ||
finally: | ||
- name: cleanup-workspace | ||
taskRef: | ||
name: cleanup-workspace | ||
workspaces: | ||
- name: shared-workspace | ||
workspace: shared-workspace | ||
--- | ||
|
||
# PipelineRun to execute pipeline - clone-into-workspace-and-cleanup-workspace | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: PipelineRun | ||
metadata: | ||
name: write-and-cleanup-workspace | ||
spec: | ||
pipelineRef: | ||
name: clone-into-workspace-and-cleanup-workspace | ||
workspaces: | ||
- name: shared-workspace | ||
volumeClaimTemplate: | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 16Mi | ||
resources: | ||
- name: app-git | ||
resourceSpec: | ||
type: git | ||
params: | ||
- name: url | ||
value: https://github.com/tektoncd/pipeline.git | ||
--- |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.