Search code examples
jenkinsgroovyjenkins-pipeline

How to get the value of a variable from DynamicReferenceParameter


I have a jenkinsfile for soapUI project.

I need get value from input. For example "threads"

[$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>

                            '''

and put it into 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'

I tried -P threads=${strategyParams["threads"]} and -P threads=${threads} and after job run I see in jenkins console empty value -P threads= .


Solution

  • The solution I got from user in jenkins comunity - helpful :)

    Jenkins community