詹金斯参数值不显示

时间:2021-06-04 09:50:48

标签: html jenkins groovy jenkins-pipeline jenkins-groovy

目标:声明一个条件多行字符串参数

方法:

我定义了两个 jenkins 参数。

  1. 主动选择参数 enter image description here
  2. 主动选择反应参考参数(选择类型:格式化HTML) enter image description here

在管道中,我只是遍历两个参数并打印它们

pipeline {

   agent any
   stages {
       stage('print each paramter') {
           steps {
               script{
                   params.each {param ->
                     println "${param.key} -> ${param.getValue()} "
                   }
               }
            }
        }
    }
}

这是输出

enter image description here

不打印第二个参数。我也试过用

回应它
echo ${inventory}
echo ${param.inventory}
echo ${params.inventory}

但它不起作用。

对如何声明条件多行字符串参数有什么建议吗?

2 个答案:

答案 0 :(得分:0)

呈现为 HTML 的主动选择反应参数只有在隐藏并格式化为输入时才能传递给构建。请参阅官方文档中的 Behavior and Rendering Summary

HTML 参数仅用于可视化目的,不用于返回用户输入值。对于构建参数,使用主动选择和主动选择反应参数。

答案 1 :(得分:0)

在文档中我们可以读到:

<块引用>

按照设计,Reactive Reference 参数的值不会传递到构建环境,只有一个重要的例外。 When the choice type is set to Formatted HTML or Formatted Hidden HTML and the HTML is an 'input' element the value can be passed to the build.有关其他说明,请参阅“高级用法”部分。

所以它似乎应该适用于格式化的 HTML。

示例:

return """<input name="value" value="${ReactiveRefParam}" class="setting-input" type="text">"""

更多信息请看这里: https://issues.jenkins.io/browse/JENKINS-53540