At the moment (Jenkins 2.22) the "Trigger builds remotely" build trigger option is visible in the multibranch pipeline job configuration, but does not work (if you check it and specify a token, it gets reset after saving anyway). According to this, it is intentional that the trigger cannot be set, but a bug that it appears as an option at all.
In the same thread they explain how to trigger builds for each individual project (branch) in a multibranch pipeline project. What I needed was a dynamic setup that would work for branches created after setting up the trigger, so rather than the suggested endpoint from the thread (/job/project-name/job-name/build
, which should have been /job/job-name/project-name/build
, since projects are created from branches in a job), I found that the endpoint to use is /job/job-name/build
. In order for that to work you have to create a user with an API token (go to Manage Jenkins -> Manage Users -> Gear icon -> Show API Token), and use those as username and password in your request.
The solution might be obvious for those used to working with Jenkins REST API, but when you are new to both multibranch pipeline projects and the REST API, it doesn't hurt to be explicit.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…