@NeoDobby with regards to the correct branch - what I had hoped to do is to send both the source and target branches as parameters, and when those parameters are present, my pipeline would merge them locally before running the build. In your case you could send an extra parameter to your pipeline called something like "Merged=true" which your pipeline could respond to by checking out the target branch rather than the source.
Having said that, I think just having a plain webhook to trigger scans on commits would probably be simpler? i.e. not use this plugin for the merge event?
%252Fin URL with a
/then I get a 404. So if the plugin is not URL encoding the branch name on the URL that could explain why it's not working; but the problem with that theory is that it works OK for the manual trigger.
After spending some more time looking into it, I've discovered the following:
In order for builds to be triggered from PR events, Jenkins needs to already be aware of the branch for the PR.
You can make Jenkins aware of the branch before the PR is created in two different ways:
1) By enabling the ref_created triggers in the Bitbucket plugin - this will cause a scan when branches are created.
2) Set Jenkins to poll every X minute to look for branches/changes
Both of these will trigger a build for the feature branch, without any pull request params.
When you run a build manually from a PR, despite Jenkins seemingly not yet knowing about the branch from a scan, it will run the build with any PR parameters fine.
Jenkins builds will only be triggered on a multibranch pipeline from a PR event IF the branch name does not contain a slash in it; i.e.
feature/myfeature. I presume there is an issue in code with URL encoding, as jenkins expects
%252F in the URL instead of a
/in my branch name
Hi - I've seen some earlier posting about this same issue, but I don't see a fix or workaround in them. I'm having an issue with manually triggering multibranch pipeline builds. Triggering via scanning works fine. It's only manual invocations that fail. Here are the details-
Here’s how I reproed the problem -
Create a simple Jenkins multibranch pipeline build using a declarative pipeline.
Set up hooks for the build in the “parameterized builds for Jenkins” config under hooks
Push a branch to the repo
Create a PR
Confirm that that the build is properly triggered
Go to the PR in BitBucket and click the triple-dot menu and select “Build In Jenkins”
Observe the “Build started” dialog
Observe the “Job was not found” dialog
Bitbucket version: 6.10.4
Jenkins version: 2.263.1
Pipeline multibranch plugin version: 2.22