6

我想在我的Jenkinsfile. 我知道如何为 BuildDiscarderProperty 做到这一点:

properties([[$class: 'jenkins.model.BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '50', artifactNumToKeepStr: '20']]])

构建另一个项目时,如何设置启动作业的构建触发器。我在Java API 文档中找不到合适的条目。

编辑:我的解决方案是使用以下代码:

stage('Build Agent'){
  if (env.BRANCH_NAME == 'develop') {
    try {
        // try to start subsequent job, but don't wait for it to finish
        build job: '../Agent/develop', wait: false
    } catch(Exception ex) {
        echo "An error occurred while building the agent."
    }
  }
  if (env.BRANCH_NAME == 'master') {
    // start subsequent job and wait for it to finish
    build '../Agent/master', wait: true
  }
}
4

1 回答 1

5

我只是在寻找同样的东西,并Jenkinsfile在 jenkins-infra/jenkins.io 中找到了这个

简而言之:

properties([
    pipelineTriggers([cron('H/30 * * * *')])
])
于 2017-01-23T17:26:35.177 回答