“Build Periodically” with a Multi-branch Pipeline in Jenkins

If you use a declarative style Pipeline and only want to trigger the build on a specific branch you can do something like this:

String cron_string = BRANCH_NAME == "master" ? "@hourly" : ""

pipeline {
  agent none
  triggers { cron(cron_string) }
  stages {
    // do something
  }
}

Found on Jenkins Jira

Leave a Comment