No "Build Triggers" option for Blue Ocean pipeline
Asked Answered
F

1

18

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. Project Configs

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. Branch Configs

So, I guess the question is, how can I add the build triggers to my blue ocean pipeline?

Ferrule answered 30/11, 2017 at 3:31 Comment(2)
Why don't Jenkins team consider this as a bug?Kenogenesis
@ShiheZhang I really don't understand either. I am not sure if it is brought up to them, but the answer below is only a partial answer. I should be able to handle this and a lot more through the "View Configurations" page.Ferrule
S
14

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")

Sturdivant answered 13/12, 2017 at 22:12 Comment(9)
Thank you so much, been looking for an answer since forever!Ferrule
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. Any other options?Diplomacy
@AmareshKulkarni good point, I don't have another option at the moment.Sturdivant
@Sturdivant looks like the notifyCommit is an option, but haven't been able to get it to work yet. I will post here, if that works out.Diplomacy
This is what I did to get this working.. curl -X POST -u "$username:$api-token" "$jenkins-url/job/$job-name/job/$branch-name/build" - This solution was quoted in another SO post or some other place, but I had to try some new options to get it it workDiplomacy
The solution that was quoted elsewhere had the buildWithParameters API and the job that I was trying to trigger was not built with any parameters, resulting in the failures. But otherwise, this API is handy to trigger remote builds within local network after pushing to GitHub or Azure repos.Diplomacy
@AmareshKulkarni Thank you for your feedback. I have included your comment in the answer for more visibility. Do you have the link to the other SO post you mention?Sturdivant
#20360310Diplomacy
@AmareshKulkarni Perfect, thank you. I have included that reference in the answer.Sturdivant

© 2022 - 2024 — McMap. All rights reserved.