简体   繁体   中英

How to invoke a pipeline based on another pipeline success using AWS CodeCommit, CodeBuild, CodePipeline

The desired behavior is as follows:

  • Push code change
  • Run unit tests for each Serverless component
  • Provided all tests are successful, deploy the components into Staging environment and mark build as successful
  • Listen to this change and run acceptance tests suite using Gherkin
  • Provided all tests are successful, deploy the components into UAT/Prod environment and mark build as successful

The desired solution would have two pipelines, the second one triggered by the first one's success.

If you have any other ideas, I'd be delighted to hear!

Thanks in advance

The solution I propose for a second pipeline trigger would be the following:

  • Have the second pipelines source as S3 (not CodeCommit). This will ensure that only when a specifically named file (object key) is pushed to Amazon S3 will this pipeline start.
  • At the end of the first CodePipeline add a Lambda function, by this point everything must have been successful to have triggered this.
  • Have that Lambda copy the artifact you build for your first pipeline and place it in the bucket with the key referenced in the second buckets source.

To keep things clean use a seperate bucket for each pipeline.

Assuming both CodePipelines are running in the same account. You can add "post_build" phase in your buildspec.yml.

In the post_build phase you can trigger the second CodePipeline using AWS SDK commands.

  build:
        commands:
            # npm pack --dry-run is not needed but helps show what is going to be published
            - npm publish
    post_build:
        commands:
            - aws codepipeline start-pipeline-execution --name <codepipeline_name>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM