Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use two sources in an AWS-CodePipeline pipeline

I have a specific case which I'm not sure if it's possible with AWS CodePipeline, and I didn't find any information about it in the documentation and event by googling....

So I would like to know if I can set two sources in a pipeline (it could be in the same stage or different stages).

Here is my use case :

  • I would like my pipeline to start when a file (a specific object) is modified in my s3 bucket
  • When this file changes and the pipeline is triggered, I would like to clone a codecommit repository and then process the build and other stages...
  • In the other hand when there is a commit on the master branch of my codecommit repository, I would like the pipeline to start and build my sources.
  • So The pipeline should be triggered either when the change comes from s3 or codecommit
  • I don't want to version the s3 file in my codecommit repository because it should be encrypted and used by others teams than dev team working with the git repository
  • And any time my pipeline starts either if it's from the s3 bucket change or the codecommit push, I should source the commit from the repository for build purposes...

I don't know if my objectives specifications are clear, if yes is it possible to use two source actions in a pipeline as described above and how to achieve this?

Thank you in advance.

Cheers, Eugène NG

like image 296
nixmind Avatar asked Apr 19 '18 16:04

nixmind


2 Answers

Yes. It is possible to have two sources for an AWS CodePipeline. Or many for that matter. The two sources have to be in your first stage.

enter image description here

Then in your build phase properties, you need to tell it that you are expecting two sources.

enter image description here

Then tell the build project which is your primary source. This is going to be the one that you want your build project to execute the codebuild.

enter image description here

From your buildspec or from any scripts you call, you can then access the source directories by referencing:

  • $CODEBUILD_SRC_DIR_SourceOutput1

  • $CODEBUILD_SRC_DIR_SourceOutput2

Just replace SourceOutputX above with what you call your output from the source stage.

I found the following link with more information: https://docs.aws.amazon.com/codebuild/latest/userguide/sample-multi-in-out.html

like image 90
Alex Nelson Avatar answered Sep 25 '22 03:09

Alex Nelson


Yes, CodePipeline allows multiple source actions in a single pipeline. A change in either source will trigger a pipeline execution. The thing to know is that every pipeline execution will pull the latest source for both actions (not just the one with a change that triggered the pipeline execution).

like image 34
Aaron Avatar answered Sep 24 '22 03:09

Aaron