user7486728
user7486728

Reputation:

Job scheduling using Jenkins pipeline

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?

Upvotes: 1

Views: 1858

Answers (1)

dot
dot

Reputation: 627

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.

Upvotes: 0

Related Questions