我想在我的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
}
}