gpt4 book ai didi

jenkins - buildingTag() 总是返回 false

转载 作者:行者123 更新时间:2023-12-03 23:52:10 25 4
gpt4 key购买 nike

每当我尝试使用 buildingTag() 创建条件阶段时,阶段总是被跳过,即使当前提交是一个标签。这是我的 Jenkinsfile:

pipeline {
agent {
docker {
image 'node:10'
}

}
stages {
stage('Build') {
steps {
sh 'yarn install'
sh 'node scripts/build.js'
}
}
stage('Lint') {
steps {
sh 'yarn lint'
}
}
stage('Deploy') {
when {
buildingTag()
}
environment {
}
steps {
sh 'node scripts/deploy.js'
sh 'node scripts/publish.js'
}
}
}
}

最佳答案

可能是由于这个错误:

https://issues.jenkins-ci.org/browse/JENKINS-55987

解决方法是:

            when {
expression {
return !isVersionTag(readCurrentTag())
}
}


和:
def boolean isVersionTag(String tag) {
echo "checking version tag $tag"

if (tag == null) {
return false
}

// use your preferred pattern
def tagMatcher = tag =~ /\d+\.\d+\.\d+/

return tagMatcher.matches()
}

// workaround https://issues.jenkins-ci.org/browse/JENKINS-55987
def String readCurrentTag() {

return sh(returnStdout: true, script: "git describe --tags").trim()
}


关于jenkins - buildingTag() 总是返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56030364/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com