1

Is there anyway to execute action in a pipeline stage based on a condition.

I mean for example, when the pipeline releases, it sources the source files at the source stage, and in the build, deploy or other stages are executed if a file exists in the artifact or is not empty...

In fact I would to execute the whole pipeline stages only when my condition is met...

Till I didn't see how to well achieve this.

What I think now to play on approval feature, I don't what you think and if one here has already had the same requirement.

1 Answer 1

2

The simplest way to achieve this is likely to add a Test stage to your pipeline. You test can simply check for the desired file in the build artifact, and simply fail the check if the file isn't there, which would halt the pipeline.

Usings tests with AWS CodePipeline

Sign up to request clarification or add additional context in comments.

3 Comments

Yes I read it, but i doesn't sound really clear for me the difference between Test Action and other action types. How to indicate a test failure to the pipeline? Is it manage internally? Do I just have to echo a non zero value in the codebuild project or raise and error? How to tell codepipeline that when the file doesn't exist it's a fail? I'm using clouformation to deploy the pipeline (an even in the console I don't see where to handle fail criteria), I really don't see how to break on fail, a sample of code could be helpfull please.
@nixmind you create tests in much the same way as a build. But if the test exits with a non-zero code, it's assuming a failed test. A simple shell script should do it. I don't have a sample code, but whatever test framework you normally use should be fine.
Ok thanks for the exit code idea, that's what I thought, so I'll try and see if it does the job for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.