【问题标题】:Jenkins Declarative Pipeline: How to call functions from "Active choices reactive reference parameter's Groovy script"?Jenkins 声明性管道:如何从“主动选择反应性参考参数的 Groovy 脚本”调用函数?
【发布时间】:2020-11-03 17:56:17
【问题描述】:

我正在尝试构建一个可以的管道,

  • 使用构建参数从用户那里获取多个输入。
  • 根据用户的第一个输入(下拉菜单),管道将更新剩余的输入选择
  • 我想根据函数的输出更新剩余的输入选择

我的做法:

  • 我正在使用“主动选择反应参考参数 (ACRRF)”groovy 脚本更新剩余的输入选择。 groovy 脚本允许用户根据引用参数设置值。

问题:

  • ACRRF 的 groovy 脚本不解析函数,即无法使用某个函数的输出更新参数值。

Reference Image

任何帮助/指导将不胜感激。

【问题讨论】:

    标签: jenkins groovy jenkins-pipeline devops


    【解决方案1】:

    为了创建基于Active Choices Parameter 的文本区域,您必须这样做:

    示例代码:

    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>"""
                    }
    

    你需要选择Choice Type作为Formatted HTML

    更多详情,请参考这篇文章:

    Jenkins generate new parameters based on another parameter value

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-10
      • 1970-01-01
      相关资源
      最近更新 更多