Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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

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.

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

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

Like Theodora Boudale likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

📣 Calling Bitbucket Data Center customers to participate in research

Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...

190 views 2 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you