如何检查参数/变量是否可用于Jenkins的“使用参数构建".在Groovy [英] How to check if parameter/variable is available for Jenkins "Build with Parameters" in Groovy
本文介绍了如何检查参数/变量是否可用于Jenkins的“使用参数构建".在Groovy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们曾经能够通过以下方式检查参数是否可用:
We used to be able to check if a parameter is available via:
binding.variables.containsKey()
或
getBinding().hasVariable()
但是,至少从Jenkins v 2.39开始,它不再起作用. (这些函数适用于常规脚本中设置的变量,但不适用于使用参数构建"中的参数.)
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'.)
推荐答案
而不是使用binding.variables.containsKey()
进行检查,您应该使用:
Instead of using binding.variables.containsKey()
to check, you should use:
params.containsKey()
这篇关于如何检查参数/变量是否可用于Jenkins的“使用参数构建".在Groovy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文