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

Controlling custom Pull Request conditions and test automation outside of the Bitbucket Cloud Edited

Matt Mikitka Feb 06, 2018

Hello,

Can you please provide guidance on how to achieve the following?

  • Creating custom Pull Request (PR) conditions
  • Controlling the values of the PR conditions outside of Bitbucket through an API
  • Building a custom PR condition on the success of automated tests executed outside of the Bitbucket pipelines (e.g., in a separate Cloud environment or on-premise)

The immediate use-case looks something like this:

  1. git push
  2. Create pull request
  3. In parallel, the following conditions must be satisfied to enable the "Complete Pull Request" button i.e., the gates to allow the Developer to complete the PR:
    1. Must have a code review and the review must pass
    2. Unit tests, executed in the pipeline, must pass
    3. Integration tests, executed outside of the pipeline, must pass

Thank you in advance,

matt

1 answer

0 votes
Philip Hodder Atlassian Team Mar 27, 2018

Hi Matt,

There's three questions here, so I'll answer them individually.

  1. You can create custom PR conditions using the Merge Checks feature in Bitbucket. On each repository, you can define rules for specific branch PRs. 
    Merge checks docs: https://confluence.atlassian.com/bitbucketserver/checks-for-merging-pull-requests-776640039.html
  2. You can control these custom PR conditions with the following REST API: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/branch-restrictions
  3. To set PR conditions to prevent merging until automated tests in a separate CI environment are complete, you can use the 'Merge Checks' feature. You'll need to integrate your tool with the build status API so that Bitbucket is aware of the result of your automated tests.
    Merge checks docs: https://confluence.atlassian.com/bitbucketserver/checks-for-merging-pull-requests-776640039.html
    Build status API docs: https://confluence.atlassian.com/bitbucket/integrate-your-build-system-with-bitbucket-cloud-790790968.html

Thanks,

Phil

Kunal Bhagawati I'm New Here Mar 12, 2019

This answer contains steps that are applicable only for BitBucket Server:
https://confluence.atlassian.com/bitbucketserver/checks-for-merging-pull-requests-776640039.html

Is there any equivalent for BitBucket cloud?

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder

...ipe.sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

1,776 views 1 18
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