groovy 如何从DynamicReferenceParameter获取变量的值

lrpiutwd  于 2023-06-21  发布在  其他
关注(0)|答案(1)|浏览(162)

我有一个用于soapUI项目的jenkinsfile。
我需要从输入中获取值。例如“线程”

[$class: 'DynamicReferenceParameter',
            name: 'strategyParams',
            referencedParameters: 'strategySelect',
            choiceType: 'ET_FORMATTED_HTML',
            description: '...',
            filterable: false,
            script: [
                $class: 'GroovyScript',
                fallbackScript: [
                    classpath: [],
                    sandbox: true,
                    script: 'return ["..."]'
                ],
                script: [
                    classpath: [],
                    sandbox: true,
                    script: """
                        if (strategySelect == 'Simple') {
                            return '''
                                <p><b>...</b><br><input type="text" class="" name="threads" value="" placeholder="Thread"></p>
                                <p><b>...</b><br><input type="text" class="" name="testDelay" value="" placeholder="Test Delay"></p>
                                <p><b>...</b><br><input type="text" class="" name="randomFactor" value="0.5" placeholder="Random"></p>
                                <p><b>...</b><br><select name="limitType" >
                                    <option>Seconds</option>
                                    <option>Total Runs</option>
                                    <option>Runs per Thread</option>
                                </select></p>
                                <p><b>...</b><br><input type="text" class="" name="testLimit" value="" placeholder="Test Limit"></p>

                            '''

并将其放入testrunner

sh '/opt/SoapUI-5.7.0/bin/testrunner.sh -P threads=${strategyParams["threads"]} -P testDelay=${strategyParams["testDelay"]} -P randomFactor=${strategyParams["randomFactor"]} -P limitType=${strategyParams["limitType"]} -P testLimit=${strategyParams["testLimit"]} loadTests.xml -s Load -c Config -r'

我尝试了-P threads=${strategyParams["threads"]}-P threads=${threads},在作业运行后,我在jenkins控制台中看到空值-P threads=

tzcvj98z

tzcvj98z1#

我从Jenkins Community的用户那里得到的解决方案-很有帮助:)
Jenkins community

相关问题