Skip to content

Add a field to Step that allows it to ignore failed prior Steps *within the same Task* #1559

@ghost

Description

This is a sub-issue of #1376 and goes a small way to supporting the functionality described there. This issue is focused solely on running Steps inside a Task when prior steps (within the same Task) have failed. This issue specifically does not deal with running whole Tasks when previous Tasks have failed.

Motivating Use Cases

  1. A unit test step fails but a subsequent step in the same Task should upload the results to a bucket regardless of that failure.
  2. A Pull Request pipeline resource should update a PR with a comment reflecting the status of a failed build. The build happens in one step and then the PR resource could inject a step at the end which runs regardless of the error and knows how to update github/gitlab/etc with the status comment.

Current Support

There currently isn't support for running a subsequent Step if a prior one has already failed in the same Task.

Suggested User-Facing Change

Add a field to the Step type that is named something like ignorePreviousStepErrors. It defaults to false. Setting this field to true will tell that Step to run regardless of whether prior steps in the same Task failed.

Example YAML:

apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
  generateName: test-and-upload-to-gcs-
spec:
  taskSpec:
    steps:
    - name: test
      image: node-run-tests
      command: ['npm']
      args: ['run', 'tests']
    - name: publish-npm-package
      image: node-publish-package
      command: ['npm']
      args: ['run', 'tests']
    - name: upload-test-results
      ignorePreviousStepErrors: true
      image: upload-test-results
      command: ['gsutil']
      args: ['cp', '/workspace/test-results.xml', 'gs://mybucket/test-results.xml']
    - name: deploy-to-prod
      image: deploy-image
      command: deploy

How would this example execute?

  1. First the node-run-tests step would execute.
  2. Let's say the unit tests fail.
  3. The next step, publish-npm-package would be skipped. This is the behaviour we currently enforce with Tekton.
  4. The next step, upload-test-results includes the ignorePreviousStepErrors field and has it set to true. Therefore this step is executed regardless of the failure in the first step.
  5. The final step, deploy-to-prod does not run because a prior step has failed.
  6. Any subsequent steps (in the same Task) that also include ignorePreviousStepErrors: true would be allowed to run.

The TaskRun would end with a Failed status, since one of its steps ended with an error, but the step to upload test results would be allowed to run regardless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.priority/awaiting-more-evidenceLowest priority. Possibly useful, but not yet enough support to actually get it done.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions