首页 > 解决方案 > 无法在 Jenkins 的活动选择参数中打印格式化 HTML 的用户输入值

问题描述

我一直在尝试使用主动选择参数来捕获用户从詹金斯输入的值。下面是我的片段

if(DB_CREATION.equals("yes")){
                                FullHTML = """
                                <p>
                                <label style="left: 22% position: absolute;">IP</label>
                                <input name='IP' type='text' class="setting-input" name="value"> </input> <br></p>
                                <p>
                                <label style="left: 22% position: absolute;">USERNAME</label>
                                <input name='USERNAME' type='text' class="setting-input" name="value"> </input><br>
                                </p>
                                <p>
                                <label style="left: 22% position: absolute;">PASSWORD</label>
                                <input name='PASSWORD' type='text' class="setting-input" name="value"> </input><br>
                                </p>
                                <p>
                                <label style="left: 22% position: absolute;">DB_NAME</label>
                                <input name='DB_NAME' type='text' class="setting-input" name="value"> </input><br>
                                </p>
                                <p>
                                <label style="left: 22% position: absolute;">DB_PASSWORD</label>
                                <input name='DB_PASSWORD' type='text' class="setting-input" name="value"> </input><br>
                                </p>
                                """
                                return FullHTML    }
                                else if(DB_CREATION.equals("no")){
                                FullHTML = """
                                <p>
                                <label style="left: 22% position: absolute;">IP</label>
                                <input name='IP' type='text' class="setting-input" name="value"> </input> <br></p>
                                <p>
                                <label style="left: 22% position: absolute;">USERNAME</label>
                                <input name='USERNAME' type='text' class="setting-input" name="value"> </input><br>
                                </p>
                                <p>
                                <label style="left: 22% position: absolute;">PASSWORD</label>
                                <input name='PASSWORD' type='text' class="setting-input" name="value"> </input><br>
                                </p>
                                """
                                return FullHTML 
                                }

管道片段如下所示 -

[$class: 'DynamicReferenceParameter', choiceType: 'ET_FORMATTED_HTML', description: '', name: 'PARAMETERS', omitValueField: false, randomName: 'choice-parameter-20993075376134551', referencedParameters: 'DB_CREATION', script: [$class: 'GroovyScript', fallbackScript: [classpath: [], sandbox: false, script: 'return[\'Would not be possible to Proceed Further\']'], script: [classpath: [], sandbox: false, script: '''if(DB_CREATION.equals("yes")){
                                FullHTML = """
                                <p>
                                <label style="left: 22% position: absolute;">IP</label>
                                <input name=\'IP\' type=\'text\' class="setting-input" name="value"> </input> <br></p>
                                <p>
                                <label style="left: 22% position: absolute;">USERNAME</label>
                                <input name=\'USERNAME\' type=\'text\' class="setting-input" name="value"> </input><br>
                                </p>
                                <p>
                                <label style="left: 22% position: absolute;">PASSWORD</label>
                                <input name=\'PASSWORD\' type=\'text\' class="setting-input" name="value"> </input><br>
                                </p>
                                <p>
                                <label style="left: 22% position: absolute;">DB_NAME</label>
                                <input name=\'MC_DB_NAME\' type=\'text\' class="setting-input" name="value"> </input><br>
                                </p>
                                <p>
                                <label style="left: 22% position: absolute;">DB_PASSWORD</label>
                                <input name=\'MC_DB_PASSWORD\' type=\'text\' class="setting-input" name="value"> </input><br>
                                </p>
                               
                                """
                                return FullHTML    }
                                else if(DB_CREATION.equals("no")){
                                FullHTML = """
                                <p>
                                <label style="left: 22% position: absolute;">IP</label>
                                <input name=\'IP\' type=\'text\' class="setting-input" name="value"> </input> <br></p>
                                <p>
                                <label style="left: 22% position: absolute;">USERNAME</label>
                                <input name=\'USERNAME\' type=\'text\' class="setting-input" name="value"> </input><br>
                                </p>
                                <p>
                                <label style="left: 22% position: absolute;">PASSWORD</label>
                                <input name=\'PASSWORD\' type=\'text\' class="setting-input" name="value"> </input><br>
                                </p>
                                """
                                return FullHTML 
                                }''']]]

我正在尝试像下面这样打印-(可能的打印)-

  echo '${params.FullHTML}'
                echo '${params.PARAMETERS}'
                echo "${params.PARAMETERS}"
                echo "${params.FullHTML}"

我正在尝试像上面那样打印所有都传递空值或什么都不传递。如何提取用户输入并将它们传递给我的测试套件?

标签: jenkinsjenkins-pipelinejenkins-groovy

解决方案


推荐阅读