当文件夹中的一些文件被推送到BitBucket时,我想运行一个多分支管道。我尝试过轮询忽略对某些路径的提交。但管道并没有触发。有人能帮忙解决这个问题吗。如何在轮询的包含区域内准确指定路径会忽略对某些路径的提交。
我在包含1.txt
和2.txt
的Git repo中使用了以下Jenkinsfile
:
pipeline {
agent any
stages {
stage('1.txt in changelog') {
when {
// see https://www.jenkins.io/doc/book/pipeline/syntax/#built-in-conditions
changelog '1.txt'
}
steps {
echo '1.txt in changelog'
}
}
stage('2.txt in changelog') {
when {
changelog '2.txt'
}
steps {
echo '2.txt in changelog'
}
}
stage('1.txt in changeset') {
when {
changeset '1.txt'
}
steps {
echo '1.txt in changeset'
}
}
stage('2.txt in changeset') {
when {
changeset '2.txt'
}
steps {
echo '2.txt in changeset'
}
}
}
}
在更改并推送2.txt
之后,根据Multibranch Pipeline项目的控制台输出显示:
...
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (1.txt in changelog)
Stage "1.txt in changelog" skipped due to when conditional
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (2.txt in changelog)
[Pipeline] echo
2.txt in changelog
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (1.txt in changeset)
Stage "1.txt in changeset" skipped due to when conditional
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (2.txt in changeset)
[Pipeline] echo
2.txt in changeset
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
这同样适用于创建2.txt
,但不适用于删除它。