example-wordpress-composer icon indicating copy to clipboard operation
example-wordpress-composer copied to clipboard

Question: How can I create MultiDev Envs on Branches creation instead of PRs?

Open nelsonamaya82 opened this issue 6 years ago • 3 comments

Hi, currently with this template, every time a new PR is created, it creates a MultiDev environment with the PR number/ID. Is there a way to change this workflow to create MultiDev environments out of feature branches instead of PRs?

Thanks.

nelsonamaya82 avatar Oct 29 '19 23:10 nelsonamaya82

@nelsonamaya82 you would need to edit bitbucket-pipelines.yml to only build specific branch patterns (e.g. feature*.)

Note that the multidev name being the pull request number is stored in the TERMINUS_ENV environment variable so you would need to ensure that is set properly as well.

ataylorme avatar Oct 29 '19 23:10 ataylorme

Thanks @ataylorme, adding the feature* pattern did the trick.

However I'm seeing something I'm not sure if is possible to fix:

  1. I created a new feature branch on my local env, did some code changes and pushed them to Bitbucket.
  2. When the new branch was created on Bitbucket, Pipelines started to run, as expected.
  3. Then the new multidev environment was created on Pantheon with ci- prefix and the CI build number.
  4. I did a minor change to my code on the same branch, pushed again to Bitbucket, Pipelines run again, but here's the issue, it creates a new multidev environment with the new CI build number. Which means each time I do any change to my code on the same branch, it will create a totally new multidev env, and it doesn't remove the previous one.

Is it possible to change the TERMINUS_ENV environment variable to use the branch name instead of the CI build number and deploy the files to the same multidev env each time the pipelines run on the same branch?

Thanks.

nelsonamaya82 avatar Oct 30 '19 12:10 nelsonamaya82

Is it possible to change the TERMINUS_ENV environment variable to use the branch name instead of the CI build number and deploy the files to the same multidev env each time the pipelines run on the same branch?

Yes, but you will need to override TERMINUS_ENV yourself after the /build-tools-ci/scripts/set-environment script is run.

A good place to do that would be in the scripts section of the default_steps.

You could either put the logic in-line or create a new bash file and call it just before echo $TERMINUS_ENV

ataylorme avatar Oct 30 '19 17:10 ataylorme