In a Jenkinsfile, to start a parameterized pipeline job from another job, I have this code snippet:
build job: 'build-sharpen-branch', parameters: [
[$class: 'StringParameterValue', name: 'BRANCHNAME', value: mergeBranchname]
]
This already works as expected, and it will start a job at URL `https://$JENKINS_URL/job/build-sharpen-branch/`.
* `iText%207%
20.NET` is the name of the Bitbucket project.
* `sharpen` is the name of the Multibranch job.
* `feature%2FQA-10738` is the name of the branch, urlencoded.
I read the following Stack Overflow questions about starting a multibranch job NOT inside a folder:
From the answers there, I gather that the syntax is `$JOB/$BRANCH` (where `$BRANCH` is URL-encoded to rename branches like `feature/foo` to `feature%2Ffoo`).
Combining the two, I conclude that the syntax for folder+job+branch is most likely `$FOLDER/$JOB/$BRANCH`.
So I tried with this code:
with
* job = `sharpen`
* branch = `${java.net.URLEncoder.encode branchName, 'UTF-8'}` *(URLEncoder to change `/` in the branch name to `%2F`)*
To my surprise, when I ran this, I got an error:
What is the correct syntax for a multibranch job inside a Bitbucket folder?