After updating the Bitbucket Pull Request Builder Jenkins plugin to version 1.4.8 to take advantage of the new Bitbucket Build Status API changes, some of our open PRs are causing Jenkins to enter an eternal loop. Ie. the plugin detects a PR, starts building, testing etc and eventually finishes. The Bitbucket Build Status is updated along the way.
However before the initial job has finished the plugin has already scheduled new build jobs for the same PR....and this goes on forever, wether we kill the jobs manually or not.
So I examined the source code for the plugin - the changes to the code from https://github.com/nishio-dens/bitbucket-pullrequest-builder-plugin/pull/66 means that no comments are added to the Bitbucket PR by the plugin for maintaining build status which in itself is very nice...but this also mean that the check for 'test this please' in BitbucketRepository.java:125 will always cause isBuildTarget() to return true, if a user has added this to the PR comments. Even if the plugin has already honoured a users request for an ad-hoc build. Ie. the plugin picks up the same 'test this please' PR comment over and over again, without knowing that it has already started (and finished) a build job for it.
1) Remove the feature entirely (non-optimal)
2) Have the plugin add a comment to the PR, saying that the 'adhoc build request' command has been completed. Though these comments in the PR add no value, this seems to be the only way to maintain state. If possible the plugin should just add a comment the first time around and then update this on subsequent build requests thus moving it to the top of the comment pile chronologically.
For now we downgraded to previous version which may be spammy in the PR comments but at least it only runs when required.