0

My Jenkins pipeline script has two presets of parameter values.

I want to create a drop-down list on the job page that would fill in default values of these parameters, while allowing users to edit them.

I've tried many variants of calls to functions of the ActiveChoices plugin but still haven't succeeded.

I have also read many similar questions here and in the Internet and have tried recipes provided in them, nothing helps.

Here is the pipeline I've got now.

properties([
    parameters([
        choice(
            choices: ['D4', 'D5'],
            description: 'Reference preset',
            name: 'reference_preset'
        ),
        [
            $class: 'DynamicReferenceParameter',
            choiceType: 'ET_TEXT_BOX',
            description: 'Path to dataset for processing',
            name: 'image_source_path',
            referencedParameters: 'reference_preset',
            script: [
                $class: 'GroovyScript',
                fallbackScript: [ classpath: [], sandbox: false, script: '' ],
                script: [ 
                    classpath: [], 
                    sandbox: false, 
                    script: """
                    if (reference_preset.equals("D4")) {
                        return 'D:\\data\\D4\\images'
                    } else if (reference_camera.equals("D5")) {
                        return 'D:\\data\\D5\\images'
                    } else { 
                        return 'unknown'
                    }
                    """ 
                ]
            ]
        ]
    ])
])

pipeline {
    options {
        ansiColor('xterm')
    }
    stages {
        stage('Build') {
            steps {
                echo "${params.image_source_path}"
            }
        }
    }
}

Screenshot of the result:

enter image description here

image_source_path does not contain D:\\data\\D4\\images, and is not editable. When I switch Reference preset from D4 to D5, its value doesn't change.

My goal is to provide editable input box having default value, based on selection from the "Reference preset".

wl2776
  • 4,099
  • 4
  • 35
  • 77

0 Answers0