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

Matt Mikitka February 6, 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
Atlassian Team members are employees working across the company in a wide variety of roles.
March 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 March 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?

Like Mike Kuth likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events