Whenever a build fails, the associated pull request should be automatically rejected. Is there any setting for that?
Hi @Eshwar Iyer,
We don't have such a setting available, however, there may be a solution by using our API to decline a PR:
Are you using Bitbucket Pipelines for your builds? And if so, do you have builds running on pull-requests?
If that's the case, you can include the following after-script in your step:
script:
- <build_commands here>
after-script:
- if [[ $BITBUCKET_EXIT_CODE -ne 0 ]]; then curl -u ${Bitbucket_Username}:${Bitbucket_AppPassword} -X POST https://api.bitbucket.org/2.0/repositories/$BITBUCKET_WORKSPACE/$BITBUCKET_REPO_SLUG/pullrequests/$BITBUCKET_PR_ID/decline; fi
where Bitbucket_Username and Bitbucket_AppPassword are Repository variables holding the Bitbucket username and app password respectively of a user that has enough permissions to decline a PR. Please note that BITBUCKET_PR_ID is available only for builds that run on pull-requests.
If you have multiple steps, you can add this after-script in all steps.
Please let me know if you're using a different CI/CD system, or if you're using Pipelines but with builds not running on pull-requests (and what you mean by associated PR in this case).
Kind regards,
Theodora
Hello @Theodora Boudale !
I was wondering if the solution to this issue is on the roadmap for BitBucket or even if there is an update as of Nov 1, 2023. Ideally an option in settings would be great to prevent Pull Requests from being raised should the build fail.
Hoping to connect with you on this issue and gain some insight.
Cheers,
Connor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Connor!
I'm afraid that this is not on our roadmap at the moment. We have a feature request about it in our issue tracker that has been closed as a result of inactivity:
You are more than welcome to provide feedback there, as our product managers continue to monitor even closed requests.
Ideally an option in settings would be great to prevent Pull Requests from being raised should the build fail
Could you please explain with an example?
A build running on a pull-requests definition in the yml cannot prevent the creation of a PR, since it is already running on an existing PR.
Do you have a branches pipeline definition running e.g. on feature branch, and are you looking to prevent PR creation with source branch feature if the build on feature fails?
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.