18
votes

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?

1
Why don't Jenkins team consider this as a bug?Shihe Zhang
@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.Blizzard

1 Answers

13
votes

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.