我在詹金斯中使用多分支插件并轮询我的git仓库以查看是否有任何更改。我的问题是,当它轮询时,我的$ GIT_BRANCH_NAME变量不存在,构建失败。检查属性是否存在Groovy
groovy.lang.MissingPropertyException: No such property: GIT_BRANCH_NAME for class: groovy.lang.Binding
at groovy.lang.Binding.getVariable(Binding.java:63)
我试图检查
if (!bindings.hasProperty(GIT_BRANCH_NAME)){
echo "Why is this not working"
env.GIT_BRANCH_NAME = sh(script: "git rev-parse HEAD", returnStdout: true).trim()
}
和
if (!project.hasProperty(GIT_BRANCH_NAME)){
echo "Why is this not working"
env.GIT_BRANCH_NAME = sh(script: "git rev-parse HEAD", returnStdout: true).trim()
}
它不工作,虽然。任何帮助表示赞赏
难道不是'hasProperty(“GIT_BRANCH_NAME”)'? – Opal
这给出了一个错误 - >'groovy.lang.MissingPropertyException:类项目:无财产groovy.lang.Binding \t在groovy.lang.Binding.getVariable(Binding.java:63) \t在org.jenkinsci .plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:224)' – Illusionist