Jenkins rebuild if destination branch been commited

Viewed 557

I use Jenkins + BitBucket to run the Unit tests for the project. To triggering to run my job "run-unit-tests" I use the BitBucket Pull Requests Builder.

Job "run-unit-tests" has workflow:

  • Merge before build
  • Bitbucket Pull request builder
  • Run Tests
  • Notification to slack

It is working perfectly if I make a single PR. For more PR's needed to Rebuild "Pending to Merge" PR's. As mentioned on "Bitbucket Pull request Builder" this procedure implement inside the plugin by clicking to option "Rebuild if destination branch changes?". But in my case this option doesn't work and if i merge some PR to master it doesn't call to Rebuild "Pending to Merge" PR's. Maybe I doing something wrong or need to carefully set up Bitbucket. Anyhow does somebody made similar pipeline, maybe exists the different way to call "Pending to Merge" PR's i.e. via Bitbucket webhook?

UPD:

I found the basic solution, but I think as soon as possible it will be deprecated(because it uses the API 1.0). I use the Bitbucket API 1.0 and 2.0. It based on plugin "Bitbucket Pull request builder". The plugin has the option Comment phrase to trigger build and it needs to assign any string, so in my case is default "test this please". Here is a simple shell script:

#!/bin/bash 
#Send message to all PR's:
for PR in `curl -s -u "$USERNAME:$PASSWORD" \
https://api.bitbucket.org/2.0/repositories/{username}/{repo_slug}/pullrequests/?state=OPEN | jq -r '.values[].id'`;
do
curl -s -u "$USERNAME:$PASSWORD"  -H "Content-Type: application/json" -d '{ "content" : "test this please" }' \
https://api.bitbucket.org/1.0/repositories/{username}/{repo_slug}/pullrequests/$PR/comments | jq ".";
done
0 Answers
Related