问题
I want know how to add values to Jenkins dropdown parameter based another parameter value.
I referred below link - Active Choices Reactive Reference Parameter in jenkins pipeline
This is my Jenkins file
#!groovy
def date = new Date().format('MM/dd/yy').toString()
properties([[$class: 'ParametersDefinitionProperty',
parameterDefinitions: [
[$class : 'ChoiceParameterDefinition',choices : 'master\nhotfix/18.3.0.35_Vol3',description: '',name: 'branchName'],
[$class: 'ChoiceParameter', choiceType: 'PT_RADIO', description: '',
filterLength: 1, filterable: false, name: 'isPublicRelease',
randomName: 'choice-parameter-1683871426502398',
script: [$class: 'GroovyScript', fallbackScript: [classpath: [], sandbox: true,
script: 'return "Error"'],
script: [classpath: [], sandbox: true,
script: '''return[
\'false:selected\',\'true\']''']]],
[$class: 'ChoiceParameter', choiceType: 'PT_RADIO', description: '',
filterLength: 1, filterable: false, name: 'isReleaseNotes',
randomName: 'choice-parameter-1683871426502398',
script: [$class: 'GroovyScript', fallbackScript: [classpath: [], sandbox: true,
script: 'return "Error"'],
script: [classpath: [], sandbox: true,
script: '''return[
\'true\',\'false:selected\']''']]],
[$class: 'StringParameterDefinition', name: 'prefixPath', defaultValue: ''],
[$class: 'ChoiceParameter',
choiceType: 'PT_SINGLE_SELECT',
description: '',
filterLength: 1,
filterable: true,
name: 'checking-ignore',
randomName: 'choice-parameter-5631314439613978',
script: [
$class: 'GroovyScript',
fallbackScript: [
classpath: [],
sandbox: false,
script:
'return[\'Could not get Env\']'
],
script: [
classpath: [],
sandbox: false,
script:
''' if (isReleaseNotes.equals("true") && isPublicRelease.equals("false")){
return["/{{:platform}}documentation/release-notes","/staging/{{:platform}}documentation/release-notes"]
}
else (isReleaseNotes.equals("true") && isBlazorPublish.equals("true")){
return["/staging/documentation/release-notes","/documentation/release-notes"]
}
'''
]
]
],
]],
[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', artifactDaysToKeepStr: '20', artifactNumToKeepStr: '30', daysToKeepStr: '20', numToKeepStr: '100']]])
node('EJ2Doc') {
try {
deleteDir()
stage('Checkout') {
checkout scm
}
}
}
and return empty value in my dropdown box in Jenkins parameter
来源:https://stackoverflow.com/questions/65183586/how-to-add-values-in-jenkins-dropdown-parameter-based-on-another-params