How to check if parameter/variable is available for Jenkins “Build with Parameters” in Groovy

萝らか妹 提交于 2020-01-30 05:43:30

问题


We used to be able to check if a parameter is available via:

binding.variables.containsKey()

or

getBinding().hasVariable()

But that no longer works at least as of Jenkins v 2.39. (These functions work for variables set within the groovy script but not the parameters from 'Build with Parameters'.)


回答1:


Instead of using binding.variables.containsKey() to check, you should use:

params.containsKey()


来源:https://stackoverflow.com/questions/42234822/how-to-check-if-parameter-variable-is-available-for-jenkins-build-with-paramete

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!