Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jenkins 如何在groovy脚本中启用/禁用文本框_Jenkins_Parameters_Jenkins Pipeline_Jenkins Groovy - Fatal编程技术网

Jenkins 如何在groovy脚本中启用/禁用文本框

Jenkins 如何在groovy脚本中启用/禁用文本框,jenkins,parameters,jenkins-pipeline,jenkins-groovy,Jenkins,Parameters,Jenkins Pipeline,Jenkins Groovy,我的Jenkins管道中有几个参数。其中,我的第一个参数是choice,第二个参数是Input Box contains string 我在这里的挑战是,当我在第一个参数中选择第一个值时,第二个参数(输入框)应该启用,如果不启用,则应该启用。我目前正在为第二个参数使用扩展选择参数,其中我选择“文本框”作为参数类型。有人能帮我在选择不同参数的值时如何启用和禁用参数输入吗 例: P1-选择参数值:启用、禁用 P2-扩展选择参数:(文本框)P2在这种情况下必须是DynamicReferencePara

我的Jenkins管道中有几个参数。其中,我的第一个参数是choice,第二个参数是Input Box contains string

我在这里的挑战是,当我在第一个参数中选择第一个值时,第二个参数(输入框)应该启用,如果不启用,则应该启用。我目前正在为第二个参数使用扩展选择参数,其中我选择“文本框”作为参数类型。有人能帮我在选择不同参数的值时如何启用和禁用参数输入吗

例: P1-选择参数值:启用、禁用
P2-扩展选择参数:(文本框)

P2在这种情况下必须是DynamicReferenceParameter,具体取决于P1

[$class: 'DynamicReferenceParameter', 
choiceType: 'ET_FORMATTED_HTML', 
description: '',
name: 'P2', 
omitValueField: true,
randomName: 'choice-parameter-123456', 
referencedParameters: 'P1',
script: [
    $class: 'GroovyScript', 
    fallbackScript: [
        classpath: [],
        sandbox: true,
        script: 
            'return [\'Error message\']'
    ], 
    script: [
        classpath: [], 
        sandbox: true,
        script: 
            """ 
                html=""
                if (P1.equals("firstValue")){
                    
                        html="<input name='value' value='' class='setting-input' type='text'>"
                }
                else {
                    html="Not applicable"
                }
                return html
            """
    ]
] ]
[$class:'DynamicReferenceParameter',
choiceType:'ET_FORMATTED_HTML',
说明:“”,
名称:“P2”,
忽略值字段:true,
randomName:'choice-parameter-123456',
referencedParameters:'P1',
脚本:[
$class:'GroovyScript',
回退脚本:[
类路径:[],
沙盒:没错,
脚本:
“返回[\'Error message\']”
], 
脚本:[
类路径:[],
沙盒:没错,
脚本:
""" 
html=“”
如果(P1.等于(“第一个值”)){
html=“”
}
否则{
html=“不适用”
}
返回html
"""
]
] ]

成功了,谢谢@rana vivek