Building multiple pipelines from different branches of a single repo #1925
Replies: 6 comments 5 replies
-
@huanjani have these discussions involved cross-account pipelines at all? Say I have a prod account and dev account and would like to create a cross-account pipeline to go from qa in our dev account to ultimately a production deployment in another account? Or do you know of any examples in which this is possible today? |
Beta Was this translation helpful? Give feedback.
-
This works but it's a pretty hacky solution because you can't view the multiple pipelines in a single file and isn't really sustainable if you want to have a bunch of pipelines (example: we need about 15 different QA sites for remote non-technical employees to be able to test distinct features). Would love to be able to add pipelines the same way we can add services, with |
Beta Was this translation helpful? Give feedback.
-
It is worth noting, that you may get some unexpected behavior if you update the pipeline file in one of the branches after setting this up. The .gitattributes doesn't apply when a FF merge can be done meaning if you update in dev and prod doesn't have a conflicting commit, it may just merge the change right over. Reference: https://stackoverflow.com/a/27234774 |
Beta Was this translation helpful? Give feedback.
-
Work on this feature is underway! |
Beta Was this translation helpful? Give feedback.
-
Hi folks! this feature is now released with https://github.com/aws/copilot-cli/releases/tag/v1.16.0 ! 🥳 |
Beta Was this translation helpful? Give feedback.
-
wooooo thank y'all!! really appreciate it:) |
Beta Was this translation helpful? Give feedback.
-
We have a more baked-in solution in the works, but in the meantime, here is a workaround for creating different pipelines for the branches of a source repository.
For the first pipeline:
copilot pipeline init
.buildspec.yml
andpipeline.yml
files are created in thecopilot
directory, check that the pipeline manifest (pipeline.yml
) has the desired branch. If not, edit the manifest to change it to the name of the current/desired branch.copilot pipeline update
to build the pipeline.For the second pipeline:
git checkout
the second git branch. Runcopilot pipeline init
. Select the same repository url as you did above.buildspec.yml
andpipeline.yml
files are created, go into the pipeline manifest file (pipeline.yml
) and change the name: field to a pipeline name that is different than that of the first pipeline, and confirm that the branch is the desired second branch.copilot pipeline update
to build the second pipeline.Sample
pipeline.yml
snippets (pay particular attention to thename
andbranch
fields):Of course, eventually you will probably want to merge dev into prod, but still maintain the separate pipelines. To do this:
.gitattributes
file in the branch to be merged into the other (here, dev)pipeline.yml merge=ours
to the file..gitattributes
file.Locally, this will prevent the pipeline manifest from being merged with the other branch and thereby maintain distinct pipelines. (See https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes.) To merge with a remote host, you'll have to manually reconcile conflicts in the
pipeline.yml
, then revert the pipeline name after merging.Let us know how this works for you!
Beta Was this translation helpful? Give feedback.
All reactions