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

How I can ensure my pipeline only runs one build at a time?


If I push to a branch whilst a build is already running, then another build is triggered. This causes problems since my builds use the shared environment. How can I force the pipeline to only run one build at a time and any commits that are pushed, are queued for the next build?

1 answer

0 votes

Hi @AshTappin_BP ,

Are both builds deploying to the same environment defined in Repository settings > Deployments?

If there is a build running that deploys to a certain deployment environment that you have defined in Repository settings > Deployments, and a second build is triggered that deploys to the same environment, then the second build gets paused and you can resume it manually when the first one finishes.

Are you using deployment environments in your yml file? Could you share the yml file you are using, so we can better help you? You may remove the commands in the scripts and just add a description of what each step does if you don't feel comfortable sharing the exact yml file here; it would be useful to have an overview of the steps and understand where the problem arises.

Kind regards,

Thank you for your reply @Theodora Boudale I am using deployments but only for the deployment steps. Here is a summary of my yaml file:

mage: atlassian/default-image:latest
- parallel:
- step:
name: "Provision CI"
image: hashicorp/terraform:full

- step:
name: "Build"
image: maven:3.6.3-openjdk-14
- step:
name: "Deploy to CI"
deployment: test
image: maven:3.6.3-openjdk-14
- step:
name: Acceptance Test

I tried adding deployment: test to every step but that wasn't allowed. I could collapse the steps into one big step. The main problem is when the Acceptance Test step is running another build could start and run the Provision CI step which alters the environment Acceptance test is using.

A feature request that could circumvent this problem is mentioned here

Hi @AshTappin_BP ,

Thank you for explaining your use case, I understand the requirement.

There is indeed a feature request about this in our issue tracker:

I added a comment there quoting your previous reply, for our product managers to take into account. You can of course add any additional feedback, if you like. I would also suggest adding your vote (by selecting the Vote for this issue link). If you'd like to get notified via email on updates, you can add yourself as a watcher by selecting the Start watching this issue link. Any updates will be posted in that feature request.

For now, the only workaround I can think of is what you said as well, combine all steps into a big one and add the deployment keyword in the step. This way, any builds that are triggered when an existing one is running will be paused, and can be resumed manually from the Pipelines page.

If you have any questions, please feel free to let me know.

Kind regards,

Thank you for your help @Theodora Boudale 

I have added my vote to the issue. We might have to do the workaround in the mean time.

Like Theodora Boudale likes this

Suggest an answer

Log in or Sign up to answer
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...

166 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