I have researched this issue a lot and cannot find an answer to that, so I have setup a simple project on Jenkins before and I get all the perks of the "Build Triggers" tab where I can select exactly what could trigger the project build (for example pull requests).
However, in the Blue Ocean project I can only see these options under the specific branch > View Configuration, and it doesn't allow me to save any of the options configured, it just shows the configs and there is no save button. I have attached the screenshots below:
This is the Project > Configuration, it allows me to save changes and everything but has no option for build triggers.
This is under Project > Branch (master) > View Configurations, it shows the build triggers I want but no option to apply these changes into that specific branch.
So, I guess the question is, how can I add the build triggers to my blue ocean pipeline?
The build triggered seen under a branch should be the reflection of the trigger directive made in a Jenkinsfile directive which is either:
cron
Accepts a cron-style string to define a regular interval at which the pipeline should be re-triggered, for example:triggers { cron('H */4 * * 1-5') }
pollSCM
Accepts a cron-style string to define a regular interval at which Jenkins should check for new source changes. If new changes exist, the pipeline will be re-triggered. For example:triggers { pollSCM('H */4 * * 1-5') }
upstream
Accepts a comma separated string of jobs and a threshold.
When any job in the string finishes with the minimum threshold, the pipeline will be re-triggered. For example:triggers { upstream(upstreamProjects: 'job1,job2', threshold: hudson.model.Result.SUCCESS) }
That would be paired with a
when
directive, which specifies the branch
branch
Execute the stage when the branch being built matches the branch pattern given, for example:when { branch 'master' }
Note that this only works on a multibranch Pipeline.
Nmaresh Kulkarni adds in the comments:
Looks like the remote trigger from script is not an option, and this option is must for folks behind a firewall.
The only way that I can think of is to create a fake trigger job, and configure that as an upstream trigger for my actual repo with Jenkinsfile.curl -X POST -u "$username:$api-token" "$jenkins-url/job/$job-name/job/$branch-name/build"
This API is handy to trigger remote builds within local network after pushing to GitHub or Azure repos.
(From "How to trigger Jenkins builds remotely and to pass parameters")