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

Merge a PR on a conditional check

Raktim
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 2, 2022

Hello Team,

We'd need to know how we can put a condition with a PR while merging this to the main branch ; so for some PRs I have 2 successful build required but for some of them I need only one green build ; How can I achieve that flexibility?

Thanks,

R..

2 answers

1 accepted

1 vote
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 3, 2022

Hello @Raktim ,

Welcome to Atlassian Community!

You can configure the merge checks by setting up  Branch permissions in your repository, where , among other possible checks,  you can define the number of successful builds required before merging to a given branch/branch pattern.

You can get more details about branch permissions in the following documentation:

However, since the merge checks in the branch permissions are configured from the pull request's destination branch perspective, and you mentioned your pull request are both merging to main branch, I'm afraid it would not be possible to configure two different rules for main branch, one requiring 1 successful build and the other 2 successful build, as Bitbucket would not be able to know when to apply one rule or another.

The only way current way to achieve different number of required successful builds would be if you were merging to different branches, so you could have one branch permissions setup for each of the destination branches.

Hope that helps to clarify your questions.

Thank you, @Raktim .

Kind regards,

Patrik S

Ulrich Kuhnhardt _IzymesCo_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
May 3, 2022

Thanks for clarifying @Patrik S - I understand that @Raktim may have 2 different _source_ branches both merging to main branch. Say we have PRs from bugfix/abc to main require 1 successful build and PRs from feature/xyz require 2 successful builds.

Can you confirm, @Raktim 

If that's the use case  - Workzone for BB Cloud is an app you can use to define such conditions.

workzone successful builds.png

The screenshot doesn't exactly show the number of required builds, but the configs have 2 and 1 required build respectively.

Disclaimer: Izymes just released Workzone Cloud (free) to the MP - let me know if you need any help setting it up.

Raktim
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 4, 2022

Hey @Ulrich Kuhnhardt _IzymesCo_ 

yes that was exactly what I wanted ; but let's say we want to configure that so that it works every time . How do I tell BB if for PR 1 is different from Pr 2 ? So I need to use some commit message or branch names ? 

Ulrich Kuhnhardt _IzymesCo_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
July 25, 2022

@Raktim - you can differentiate by specifying the source branch and the destination branch in Workzone settings. The required number of successful build will be checked for every PR from the source to destination branch.

Changing the required number of build dynamically when you create the PR (just like adding reviewers) isn't possible AFAIK.

0 votes
Ulrich Kuhnhardt _IzymesCo_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
May 2, 2022

As far as I know required build results can only be set to an absolute number in Bitbucket cloud.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events