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

后端 未结 5 763
南旧
南旧 2020-11-30 20:29

I\'m running Jenkins 2 with the Pipeline plugin. I have setup a Multi-branch Pipeline project where each branch (master, develop, etc.) has a Jenkinsfile in the root. Settin

5条回答
  •  星月不相逢
    2020-11-30 20:53

    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

提交回复
热议问题