Continue Tekton pipeline after failure (similar to jenkins pipeline catchError behaviour)

2.5k views Asked by At

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 ?

2

There are 2 answers

0
gsaslis On

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.

1
Dewan Ahmed On

"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#