我在詹金斯中使用多分支插件並輪詢我的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