我有一个Jenkins管道,它根据对特定文件夹的更改触发下游作业。第一次构建时不会触发下游作业。Jenkins日志显示:Warning, empty changelog. Probably because this is the first build.
。如何使管道在第一次构建时触发下游作业?
agent { label 'slave-02'}
options {
skipDefaultCheckout true }
stages {
stage('checkoutscm') {
steps {
checkout([$class: 'GitSCM', branches: [[name: "${BRANCH_NAME}"]], doGenerateSubmoduleConfigurations: false, submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'xxxxx', url: 'https://git.xxxx.com/xxx/xxx.git']]])
}
}
stage('DeployRelease') {
when {
anyOf {
changeset "scripts/**"
changeset "config/**"
}
}
steps {
build job: "/DEVOPS_DUMMY/${BRANCH_NAME}", wait: false
}
}
stage('DDLDelivery') {
when {
changeset "DDL/**"
}
steps {
build job: "/PROD/${BRANCH_NAME}", wait: false
}
}
}
} ```
2条答案
按热度按时间lc8prwob1#
不知道你用的是哪个git插件,但我在bitbucket插件上遇到了同样的问题。把pr发现策略从
Merging the pull request with the current target branch revision
改为the current pull request revision
就解决了这个问题。kulphzqa2#
我试图解决同样的问题,并结束了这个解决方案:
检查
currentBuild.previousCompletedBuild != null
比检查env.BUILD_NUMBER == '1'
好(也可以在互联网上找到),因为如果第一次运行由于某些原因而中止,那么下一个构建将有env.BUILD_NUMBER == '2'
,但它也不会有更改。检查currentBuild.previousCompletedBuild != null
保证了之前至少有一个成功的构建,我们可以检查它的更改。