4

I have a pipeline where I want to:

  1. provision some resources,
  2. run some tests,
  3. tear down the resources.

I want the tear down task, in step 3, to run regardless of whether tests passed or failed, in step 2. As far as I’ve understoood runAfter only runs a task, if the previous task succeeded.

I tried looking into Conditions, but can’t seem to find an example…

Anything else I can use or some example someone could point me to ?

gsaslis
  • 3,066
  • 2
  • 26
  • 32

2 Answers2

7

"finally" clause is implemented in Tekton Pipelines (Apr'20)

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

Design document: Design doc: https://docs.google.com/document/d/1lxpYQHppiWOxsn4arqbwAFDo4T0-LCqpNa6p-TJdHrw/edit#

Dewan Ahmed
  • 175
  • 1
  • 7
0

It turns out this is not yet supported in Tekton, at the time of writing.

It is, however, work-in-progress in the tektoncd/pipeline project, in this PR.

gsaslis
  • 3,066
  • 2
  • 26
  • 32