Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Block merge on BitBucket until Jenkins task is completed

I'm looking for some way to block a possibility of making merge of pull requests on the BitBucket if some specified Jenkins task is currently running. Do you know if it is possible? I was looking for that in the Jenkins Git plugin and in the settings of BitBucket but with no success... Thank you in advance for any help!

like image 587
wojtek1902 Avatar asked Jan 26 '18 10:01

wojtek1902


2 Answers

In bitbucket go to the project and then the repository you want to enable this feature for, and under settings->pull request check the option

Requires a minimum of [n] successful builds

like image 150
cantSleepNow Avatar answered Sep 22 '22 16:09

cantSleepNow


This can be done using the bitbucket build status api.

1) Enable require minimum 1 successful builds in bitbucket repo settings https://blog.bitbucket.org/2015/11/18/introducing-the-build-status-api-for-bitbucket-cloud/

Then either: Manually in jenkins pipeline fire the API calls to set the build status to in in progress, failed, success

Alternatively, using something like the https://wiki.jenkins.io/display/JENKINS/GitHub+Branch+Source+Plugin which will do this automatically for you (sending the statuses) plus a host of other things (like automatically discovering new repos with Jenkinsfiles)

like image 24
metalisticpain Avatar answered Sep 20 '22 16:09

metalisticpain