Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,466,394
Community Members
 
Community Events
176
Community Groups

Is it possible to reference deployment name dynamically in bitbucket-pipelines.yaml?

We are using Bitbucket Pipelines as a CI/CD service. I am trying to deal with one inconvenience --> The inability to trigger multiple concurrent deployments with the same name. BB docs

Consider the following example:

stepdefinitions:

  - prepare-and-test:  &prepare-and-test
      name: Prepare and Test
      script:
        - export DEV_ENV="${BITBUCKET_BRANCH}"
        - Do some other stuff
        

  - build-and-deploy: &build-and-deploy
      name: Build and Deploy
      deployment: personal-dev-env
      script:
        - export DEV_ENV="${BITBUCKET_BRANCH}"
        - Do some other stuff


pipelines:
  branches:
    dev-*:
      - step: *prepare-and-test
      - step: *build-and-deploy

Explination:

dev-$some_integer is a git branch and corresponds to a particular developer in our organization but also corresponds to his personal develop environment. The idea here is whenever a code change is made --> trigger BitBucket pipeline that will reflect this change on the corresponding env/server.

Example:

Let's say we have 3 repos - webserver, php, database.

Now dev-3 wants to change his webserver config, so he checks out dev-3 branch in webserver repo --> makes changes --> pushes to dev-3 branch --> His changes are automatically deployed to dev-3 env/server.

So far so good, however let's imagine we have 100 developers/branches and want to make one change and deploy it to all dev envs. Example:

Let's checkout master branch --> make the change --> push

Now let's merge master branch into all dev-** branches (let's say they are 100) so that the change is reflected on all dev environments.

This is where the inconvenience happens, as BitBucket attempts to start 100 pipelines with a deployment with the same name and refuses to do so. The end result is that 99 pipelines are now paused and expect a manual action to be resumed. This means one should wait for each pipeline just to click 'Resume' button on the 'Paused' pipeline.

I can totally agree that this restriction is there for a very good reason, however it's just not potentially destructive in any way for my particular use case.

I was therefore disappointed to find out that there's no way to skip/ignore this enforcement, OR just auto-resume paused pipeliens.

To deal with this we have currently created 100 environments both in the repository settings (BitBucket GUI menu) with a differant name and have this in our bitbucket-pipelines.yaml :

    pipelines:
branches:
     dev-1:
       - step: *prepare-and-test
       - step:
           <<: *build-and-deploy
           deployment: personal-dev-01
     dev-2:
       - step:
           <<: *build-and-deploy
           deployment: personal-dev-02
    etc..

This approach totally deals with the pauses, as the deployments now have differant names and they can run concurrently . However, what i don't like about this approach is that if another 10 developers join us --> another 10 BitBucket environments should be added in BB UI (repository settings) and 10 more branches must be explicitly specified in the bitbucket-pipelines.yaml. And this is per repo ! (Obviously this doesn't look sane ...)

I thought about using ${BITBUCKET_BRANCH} variable to dynamically specify the deployment's name based on branch, something like this:

  deployment: personal-dev-"${BITBUCKET_BRANCH}"

However i found that BB vars won't expand in the scope i wanted them too.

Another idea would be to use nodejs/husky to trigger a git hook that will edit the bitbucket-pipelines.yaml file based on checked-out branch whenever a merge is made. (Or something similar)

However i feel this is totally going in the wrong direction and there must be a simpler, cleaner way to :

  • Specify deployment name in bitbucket-pipelines.yaml dynamically, based on checked-out branch. Or
  • Deal with the pauses in another way entirely ?

I do hope my question is clear enough, but let me know if additional explination is needed somewhere.

1 answer

1 accepted

0 votes
Answer accepted

Hi @peter, welcome to the community and thank you for explaining your use case.

I'm afraid that none of the features you are looking for are available at the moment. We have a feature request in our issue tracker for both.

Ability to specify a variable for a deployment environment:

Automatic resuming of paused deployments:

I don't have an ETA to share, implementation of new features is done as per our policy here and any updates will be posted in the feature request.

I would suggest adding your vote in each feature request (by selecting the Vote for this issue link) as the number of votes helps the development team and product managers better understand the demand for new features.

You are more than welcome to leave any feedback, and you can also add yourself as a watcher (by selecting the Start watching this issue link) if you'd like to get notified via email on updates.

Kind regards,
Theodora

Thank you for your reply Theodora,

I will follow your advice and vote/follow the feature request.


You are welcome Peter, please feel free to reach out if you ever need anything else.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events