简体   繁体   English

Jenkins 声明式管道:如何从“主动选择反应引用参数的 Groovy 脚本”调用函数?

[英]Jenkins Declarative Pipeline: How to call functions from "Active choices reactive reference parameter's Groovy script"?

I am trying to build a pipeline that can,我正在尝试建立一个可以,

  • take multiple inputs from a users using build parameters.使用构建参数从用户那里获取多个输入。
  • Based on the user's first input(a drop-down), the pipeline would update the remaining input choices .根据用户的第一个输入(下拉列表),管道将更新剩余的输入选项
  • I want to update the remaining input choices based on output of a function.我想根据函数的输出更新剩余的输入选项

My approach:我的做法:

  • I am updating remaining input choices using "Active choice reactive reference parameter(ACRRF)" groovy script.我正在使用“主动选择反应参考参数(ACRRF)”常规脚本更新剩余的输入选择 The groovy script allows users to set a value based on the reference parameter. groovy 脚本允许用户根据引用参数设置一个值。

Problem:问题:

  • The ACRRF's groovy script does not parse the function ie the parameters value can not be updated using the output of a certain function. ACRRF 的 groovy 脚本不解析该函数​​,即无法使用某个函数的输出更新参数值。

Reference Image参考图片

Any help/guidance would be highly appreciated.任何帮助/指导将不胜感激。

In order to create a text area based on the Active Choices Parameter , you have to do like this:为了创建基于Active Choices Parameter的文本区域,您必须这样做:

Sample code:示例代码:

if (data_center.contains('DC01')){
   return """<textarea name="value" rows="5" class="setting-input">
             </textarea>"""

          } else

if (data_center.contains('DC02')){
         return """<textarea name="value" rows="5" class="setting-input">
                     </textarea>"""
                }

You need to select Choice Type as Formatted HTML您需要选择Choice Type作为Formatted HTML

For more details, please refer this post:更多详情,请参考这个帖子:

Jenkins generate new parameters based on another parameter value Jenkins 根据另一个参数值生成新参数

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

相关问题 jenkins 管道中的主动选择反应参考参数 - Active Choices Reactive Reference Parameter in jenkins pipeline 如何从 Jenkins 的活动选择反应参数中引用节点参数 - How to reference the node paramater from the active choices reactive parameter in Jenkins Jenkins Groovy 和 Active Choices 反应参数 - Jenkins Groovy and Active Choices Reactive Parameter Jenkins - 如何在声明性管道中指定 Active Choice Reactive 参数? - Jenkins - How to specify an Active Choice Reactive parameter in a declarative pipeline? 在活动选择反应参数中使用groovy脚本 - Using groovy script in active choices reactive parameter 如何在詹金斯的另一个活动选择参数的groovy脚本中读取活动选择参数的值? - how read active choices parameter value in another active chocices parameter's groovy script in jenkins? K8s 在 Active Choices Reactive Reference Parameter 脚本中 - k8s in Active Choices Reactive Reference Parameter script Jenkins:从Active Choices参数groovy脚本访问其他插件 - Jenkins: Accessing other plugins from Active Choices Parameter groovy script 主动选择反应性参考参数,格式为 html,在 jenkins 管道中具有默认值 - Active choices reactive reference parameter as formatted html in jenkins pipeline with default value 如何从Jenkins中的Active Choices插件groovy脚本执行shell - How to execute shell from Active Choices Plugin groovy script in Jenkins
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM