小编use*_*878的帖子

如何在jenkinsfile中定义jenkins构建触发器以在其他工作之后开始构建

我想在中定义构建触发器Jenkinsfile。我知道如何为BuildDiscarderProperty执行此操作:

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

构建另一个项目后,如何设置启动作业的构建触发器。我在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
  }
}
Run Code Online (Sandbox Code Playgroud)

build-triggers jenkins-pipeline

5
推荐指数
1
解决办法
5572
查看次数

标签 统计

build-triggers ×1

jenkins-pipeline ×1