screwdriver icon indicating copy to clipboard operation
screwdriver copied to clipboard

Trigger job on a failed build

Open drewfish opened this issue 6 years ago • 2 comments

What happened: I want to run a job if by current job's build fails, however there is no existing feature. This is so that I can do actions rollback or cleanup after a deployment job.

What you expected to happen:

Some way for job B to run if job A fails. This would be especially useful for template pipelines, where I (as template author) would want to setup some negative tests (make sure template fails build correctly) for the newly-created template version.

As a random idea, perhaps specify this in requires somewhere, e.g. requires: [ validate-pass, !validate-fail ].

How to reproduce it:

drewfish avatar May 22 '18 22:05 drewfish

I want to rollback automatically when a deploy job or some functional test is failed.

an example sd.yaml is like below:

shared:
  image: kubectl-available-image

jobs:
  deploy:
    requires: [~commit]
    steps:
      - deploy: kubectl apply -f foo-deployment.yaml
  functional-test:
    requires: [deploy]
    steps:
      - test: some test
  rollback:
    requires: [failed@functional-test]
    steps:
      - rollback: kubectl rollout undo deploy/foo-deployment

Related:

tk3fftk avatar Dec 16 '19 03:12 tk3fftk

We still receive requests for this feature every now and then. I feel that we are approaching the stage where we can seriously consider implementation.

For reference, CircleCI seems to provide a similar functionality with when: on_fail. https://circleci.com/docs/2.0/configuration-reference/#the-when-attribute

wahapo avatar Mar 03 '22 01:03 wahapo