jenkins - groovy.lang.MissingPropertyException:没有这样的属性:类的脚本:groovy.lang.Binding
问题描述
我正在尝试使用 Jenkinsfile(groovy 脚本)获取提交者的电子邮件地址
我使用了这里批准的解决方案: https ://stackoverflow.com/a/46648279/10899655
我的代码:
@Library('shared-libraries') _
pipeline{
//my stages here
}
post {
always {
script {
def changeSet = script.currentBuild.changeSets[0];
Set authors = [];
if (changeSet != null) {
for (change in changeSet.items) {
authors.add(GetUserEmail{user=change.author})
}
}
}
}
}
但是我收到此错误消息:
Error when executing always post condition:
groovy.lang.MissingPropertyException: No such property: script for class: groovy.lang.Binding
我该如何解决?
先感谢您
解决方案
您没有script
在该行中定义变量
def changeSet = script.currentBuild.changeSets[0];
你需要先定义它。