bitbucket-branch-source-plugin
bitbucket-branch-source-plugin copied to clipboard
Webhook for target branch update should trigger PR builds
-
[ x] Jenkins version
-
[ x] Plugin version
-
[ ] Bitbucket cloud
-
[ x] Bitbucket server and version
Description
Jenkins LTS 2.204.6 Bitbucket Branch Source Plugin 2.7.0 Branch API Plugin 2.5.5 Pipeline Multibranch Plugin 2.21
Bitbucket Server v6.10.4 Bitbucket Post Webhooks plugin 2.5.3
We have our multibranch builds configured with the "Merging the pull request with the current target branch revision" strategy. We use webhooks (Bitbucket Post Webhooks) to trigger multibranch builds and the multibranch project is configured to scan every 4 hours. What we see is that when the target branch is updated, it doesn't trigger a build of all PRs by the webhook. However, the scan (that happens every 4 hours) does find this change and triggers builds. This is not obvious for the users and confuses them. Also the delay for the build could be a problem as one could merge the PR before the build is triggered and if the target branch update then causes a problem for the PR this is noticed after the merge. Preferrably the webhook for the update on a branch should also trigger a build of every PR job that is configured with a merge strategy (as there is a change). (Another solution si to scan every minute but we don't want to do that as it causes unnecessary load on the Bitbucket Server.)
Are you letting the plugin manage webhooks for you or did you set them up yourself?
@deebloo No we're not. But we set up the webhhooks the same way and webhooks are called for changes to the target branch. It's just that we don't see that changes to the target branch causes rebuilds of any PR with this strategy as we think should happen.
Can you share your web hook config? A couple issues I have seen have been when not using the Team/Project way of managing. I wonder if something is wrong with just multibranch
Please note that we're using Bitbucket Post Webhook plugin, not native Bitbucket webhooks.
So, to be clear, the use case I'm describing is something that should be handled already? I.e. all PRs that have a merge strategy should rebuild when the target branch is updated?
Ah ok. And that IS working when using native webhooks.
Thanks for confirming. I tried to verify but for some reason I can't get the native webhook to work though, not sure why. We're currently not using native webhooks as they doesn't support PR updates in Bitbucket 6 (support added in Bitbucket 7).
Even i have the same requirement and same issue. PRs wont build automatically when a target branch is updated. And also the native implementation is not working.
I tried the build strategy for this requirement but it still does not trigger the target branches.(Kept it unchecked)
Jenkins version: Jenkins 2.235.5 Bitbucket branch source version: 2.9.2 basic-branch-build-strategies version: 1.3.2 Bitbucket version: v6.10.4
@andham Have you found a fix or workaround for this issue? Thanks in advance!
No, haven't found a fix or workaround unfortunately. Still an issue for us.
@dsakilesh where can I find the "Build strategies / Change request" config section? I have a multi branch pipeline set up and can't see that section. (In my case my team explicitly doesn't want rebuilds when the target branch changes, but I have been unable to configure that yet. :( ) Thank you for your help - or anyone else who can help me out. :) (@deebloo or anyone?)
@tfink-cc you need to install Basic Branch Build Strategies for that options. https://plugins.jenkins.io/basic-branch-build-strategies/
Thank you @dsakilesh that will help me a lot - if it hopefully works like I am expecting it to do right now. :) (y)
I am curious if anyone was able to get a work around or scenario to work to enable this? @tfink-cc did your config update work? We are facing a similar issue of wanting to have PRs that are outstanding automatically re-run if the target branch is updated while that PR is still open (basically if a different PR "wins" the merge race).
@begoldsm my setup is working well now, but I am understanding that you are looking for the opposite behavior then what I was looking for. We didn't want PRs to run again, when the target branch had changed (for some issue involving a particular resource forming a bottleneck in our process). From my understanding the behavior you are looking for (PRs being rebuild when the target branch changes) is the default behavior anyways. 👍
Oh that is a good call, yes, I do want the opposite (for it to trigger a rebuild of the PR when the target changes), however I didn't know this was supposed to "just work" out of the box, since it currently isn't for us :(. Can someone share a representative config that does do that? Here is what I have tried:
- use native webhooks (no option for changes to target branch there, but I did select source branch, to see if it worked)
- Use post webhooks (same deal about events missing for target branch change)
- Used the basic build strategies plugin to add the PR strategy and keep the "ignore" box unchecked
- Tried without the basic build strategies plugin as well
We are using the bitbucket branch source latest and multibranch pipelines that are configured to "merge PR with target" as the discovery strategy.
Hi @begoldsm, were you able to find a solution to this problem? Currently experiencing the same issue on our Jenkins instance.
@andham, were you able to find a solution to this?
I need this feature too. anyone found a solution?