鉴于以下管道:CHANGE_AUTHOR_EMAIL和CHANGE_ID环境变量返回“没有这样的属性:......”
stages {
stage ("Checkout SCM") {
steps {
checkout scm
sh "echo ${CHANGE_AUTHOR_EMAIL}"
sh "echo ${CHANGE_ID}"
}
}
}
为什么这些变量无法解析,并提供价值?
最后,我想用这些环境变量来发送电子邮件和合并拉请求:
post {
failure {
emailext (
attachLog: true,
subject: '[Jenkins] $PROJECT_NAME :: Build #$BUILD_NUMBER :: build failure',
to: '$CHANGE_AUTHOR_EMAIL',
replyTo: '[email protected]',
body: '''<p>You are receiving this email because your pull request was involved in a failed build. Check the attached log file, or the console output at: $BUILD_URL to view the build results.</p>'''
)
}
}
和
sh "curl -X PUT -d '{\'commit_title\': \'Merge pull request\'}' <git url>/pulls/${CHANGE_ID}/merge?access_token=<token>"
奇怪的是,$PROJECT_NAME
,$BUILD_NUMBER
,$BUILD_URL
做的工作......
更新:这可能是一个开放的bug ... https://issues.jenkins-ci.org/browse/JENKINS-40486 :-(
是否有任何解决方法来获取这些值?
这个复选框在哪里?我无法在我的多分支作业中找到它 – SILENCE
插件已被更新,此答案不是有效的。需要更新自己,所以我可以更新答案 –