Allow transition to next stage in AWS pipeline even if a stage produces a failure

3.1k views Asked by At

I'm looking to see if the AWS code-pipeline is configurable to temporarily allow transitions to the next stage even if failures are encountered. So far I've found that it is possible to enable and disable transitions (http://docs.aws.amazon.com/codepipeline/latest/userguide/transitions.html#transitions-disable-enable-console) however if disabled this just stops the pipeline at that point regardless of whether any failures were produced in a stage. What I'd like to do is have the option to skip past a failing stage so the pipeline proceeds right to the end regardless of failing tests etc.

2

There are 2 answers

0
TimB On BEST ANSWER

There currently isn't an option to skip a failed action.

The only option to bypass a failing stage would be to edit the pipeline to remove the action and re-run it.

0
Badr B On

I don't think there's any first-class support for this, but there are some workarounds. The one I'm going to outline assumes that you're using CodeBuild and just want to skip the stage with failing tests.

You can have a flag stored somewhere (e.g. AppConfig, DynamoDB, S3, SSM parameter store, etc.) that indicates whether tests should be skipped. If this flag is true, then the CodeBuild stage exits with status code 0 (indicating success). You can have some simple CLI that does this logic. Please note that you should set this flag to false (i.e. don't skip tests) before exiting the stage. This ensures that the next run won't skip tests, assuming that's the desired behavior.

To skip the stage following a previous failure, you can wrap the flag setting and retry invocation using a Lambda function. So the developer experience would look something like:

  1. Developer gets notified of failed tests
  2. Developer verifies if failed tests can be skipped
  3. If tests can be skipped, navigate to Lambda console and invoke SkipTests function.

The SkipTests function would:

  1. Set skip tests flag to true
  2. Invoke stage retry (https://docs.aws.amazon.com/codepipeline/latest/userguide/stage-retry.html)

After this, the failed stage would effectively be skipped, keeping all artifacts the same.