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

Bitbucket Pipelines- Same Steps but against different environment variables(Deployment)

Midhun Mohan March 22, 2021

I have a use case like below

 -  we have a release branch

 - Defined steps for build and deploy to destination from release branch in bitbucket-pipelines.yml

 - Defined 3 different Destination as testing, staging and production 

 

Question is, can we run pipeline against different destination but using the same release branch commit and same steps of build and deployment.

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 24, 2021

Hi @Midhun Mohan  and welcome to the community.

When you say that you defined 3 different destinations as testing, staging and production, I assume that you defined them as deployment environments from Repository settings > Deployments?

If so, you can define different variables for each deployment environment from this page.

Based on the description of your use case, you could configure the bitbucket-pipelines.yml file as follows:

pipelines:
branches:
release:
- step:
name: Build
script:
- <command 1>
- <command 2>
- step:
name: Deploy to testing
deployment: testing
script:
- <command to deploy>
- step:
name: Deploy to staging
deployment: staging
script:
- <command to deploy>
- step:
name: Deploy to production
deployment: production
script:
- <command to deploy>

With a yml file like above, each push to the release branch will trigger the Build step, and then the deployment steps to the 3 different environments.

I'm not sure if your question is about something different. In case I have misunderstood what you are asking, please feel free to clarify so I can better help you.

Kind regards,
Theodora

Midhun Mohan March 24, 2021

Thanks for the response,

The mentioned steps, we already tried and its working.

The scenario here is bit different, means we have a build script, only those environment related variables has to be changed for each deployment(to dev , staging etc). So, if there is any way without updating yml each time for a new environment( say staging-2) we can run the pipeline. Only effort will be configuring the new environment under deployments.

Just to be simple, we need to check with you that can we select a deployment from a dropdown when running a pipeline so that the variables will be used from that.

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 31, 2021

Hi @Midhun Mohan,

Thank you for your reply and the clarification.

If you want to add and use a new environment under Deployments, then this needs to be added in the bitbucket-pipelines.yml file as well, with the keyword deployment for the relevant step.

Pipelines builds run based on the content of the bitbucket-pipelines.yml file and at the moment the deployment environment needs to be stated explicitly in the bitbucket-pipelines.yml file for the relevant step.

I'm afraid that it is not possible to have a deployment step where you can choose the environment from a dropdown.

Kind regards,
Theodora

Midhun Mohan March 31, 2021

ya got to know that few days before, thanks for the confirmation.

Like Theodora Boudale likes this
Brigitte Bedard October 31, 2023

@Theodora Boudale You know you can't do that, right? You can only define a particular deployment environment ONCE per pipeline.

As per BB customer support 

https://community.atlassian.com/t5/Bitbucket-questions/Usage-of-Deployment-variables-on-multiple-steps/qaq-p/1103443?anon_like=1313162

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 31, 2023

Hi Brigitte!

You can only define a particular deployment environment ONCE per pipeline.

None of my replies here mention the opposite, the topic discussed in this question is different.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events