简体   繁体   English

Jenkins:在参数化构建中访问 groovy 中的参数时出错

[英]Jenkins : Error accessing parameters in groovy for a Parameterized Build

I am trying to access choice parameters set in the This build is parameterized in a Groovy build script , for a Jenkins freestyle job.我正在尝试访问在此构建中设置的选择参数在Groovy 构建脚本中参数化,用于 Jenkins 自由式作业。

在此处输入图片说明

I tried using the List as println {params.List} but it did not work and gave following output :我尝试使用 List 作为println {params.List}但它不起作用并给出了以下输出:

在此处输入图片说明

I have referred other similar posts on Stackoverflow, but nothing seems to have worked for me.我在 Stackoverflow 上提到了其他类似的帖子,但似乎没有任何效果对我有用。 I have also tried params.List {List} List and got following error with ${env.List} & ${params.List}我也试过params.List {List} List并得到以下错误${env.List} & ${params.List}

groovy.lang.MissingMethodException: No signature of method: Script1.$() is applicable for argument types: (Script1$_run_closure1) values: [Script1$_run_closure1@159f1360] 11:12:48 Possible solutions: is(java.lang.Object), run(), run(), any(), use([Ljava.lang.Object;), any(groovy.lang.Closure) groovy.lang.MissingMethodException:无方法签名:Script1.$() 适用于参数类型:(Script1$_run_closure1) 值:[Script1$_run_closure1@159f1360] 11:12:48 可能的解决方案:is(java.lang. Object), run(), run(), any(), use([Ljava.lang.Object;), any(groovy.lang.Closure)

How should I be calling the List correctly such that it prints out the choice I selected while running build with parameters?我应该如何正确调用 List 以便在运行带参数的构建时打印出我选择的选项? Looking for some guidance on this.寻找这方面的一些指导。 Thanks in advance.提前致谢。

Passing $List from properties and using the new variable 'props_list' in script worked!从属性传递$List并在脚本中使用新变量“props_list”有效!

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM