1

We have a multibranch pipeline for our Jenkins job configuration. We have three branches: develop, master and feature branch. Developers want to run feature branch periodically every day. We are using same Jenkinsfile for several projects.

For running periodically, I have added below lines to my feature branch.

properties([[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', artifactDaysToKeepStr: '10', 
    artifactNumToKeepStr: '10', daysToKeepStr: '10', numToKeepStr: '10']], gitLabConnection('GitLab'), pipelineTriggers([[$class: 'TimerTrigger', spec: '0 5,12 * * *']])])

The problem is that we have 5 projects and all of them are being executed at the same time as they are using same Jenkinsfile. Is there any way that I can run those projects one by one?

Szymon Stepniak
  • 40,216
  • 10
  • 104
  • 131

1 Answers1

0

You should try prefixing the trigger with 'H/' spec: spec: 'H 5,12 * * *' instead of spec: '0 5,12 * * *'

Jenkins evenly distributes the jobs when multiple jobs have same pattern that trigger at same time.

Meaning of H prefix is explained here.

dot
  • 597
  • 1
  • 4
  • 25
  • Great Info..! Meaning of H prefix I see that **H/5 in the first field means Every five minutes starting at some time between 0 and 4 minutes past the hour** so if i keep H/0 will it run randomly in that 0-59 sec? thanks again –  Feb 14 '18 at 20:28
  • Well, I think you should use H 5,12 * * *. This represents Jenkins build to run once at given hour every day. – dot Feb 15 '18 at 02:42
  • Actually, I would like to run morning 6 am and afternoon 4pm everyday. @dot –  Feb 15 '18 at 14:57
  • In that case it would be H 6,16 * * * – dot Feb 15 '18 at 15:00