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,560,249
Community Members
 
Community Events
185
Community Groups

Can I Make Pipelines Wait If A Pipeline In Another Repo Rinning?

Let's say I have two repositories, repository_a and repository_b

Whenever a merge happens in repository_b, a pipeline is triggered to push some code to my cloud service. I would like to a configure it so if a merge happens in repository_b, Bitbucket will check to see no pipelines are running in repository_b and if there are, wait until repository_a's pipeline is done before running the pipeline

Is there an option to do this?

1 answer

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

Hi @NZ and welcome to the community.

You mentioned:

Bitbucket will check to see no pipelines are running in repository_b and if there are, wait until repository_a's pipeline ...

I believe you mean that Bitbucket should check if no pipelines are running in repository_a instead? And then wait until repository_a pipelines are finished?

There is no out-of-the-box feature to do this, but you could do it with a script using our API.

You can write a script with a while loop that checks if there are any pipelines with status PENDING, BUILDING or IN_PROGRESS in repository_a.

If there are, wait for e.g. 30 seconds or a different duration (depending on how much time builds in repository_a usually take) and repeat the loop.

When there are no pipelines with these statuses in repository_a, then exit the script.

You can then execute this script at the beginning of the build in repository_b, and when the script exits successfully, the rest of the build's commands will be executed.

You can use the following API endpoint to retrieve pipelines in repository_a

and you can filter by the statuses I mentioned as follows:

https://api.bitbucket.org/2.0/repositories/my-workspace/repository_a/pipelines/?sort=-created_on&status=PENDING&status=BUILDING&status=IN_PROGRESS

where my-workspace replace with the workspace id where repository_a belongs, and repository_a replace with the repo slug for that repo.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events