Created
June 19, 2018 07:50
-
-
Save jkroepke/4687190160ff699f8098709b721866d0 to your computer and use it in GitHub Desktop.
Extended Choice Parameter - Emulate Peristent Parameter Plugin for Pipelines 2.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def choiceGroovyScript = ''' | |
try { | |
return jenkins.getItemByFullName(jobName).getLastBuild().getProperties()["environment"][parameterName] | |
} catch (all) { | |
return defaultValue | |
} | |
'''.trim() | |
job('JOB_NAME') { | |
configure { project-> | |
project / 'properties' / 'hudson.model.ParametersDefinitionProperty' / parameterDefinitions << 'com.cwctravel.hudson.plugins.extended__choice__parameter.ExtendedChoiceParameterDefinition' { | |
name 'DOCKER_TAG' | |
// https://issues.jenkins-ci.org/browse/JENKINS-25051 | |
// https://github.com/jenkinsci/job-dsl-plugin/wiki/The-Configure-Block#concurrentmodificationexception | |
delegate.description('Docker Build Tag') | |
quoteValue 'false' | |
multiSelectDelimiter ',' | |
type 'PT_TEXTBOX' | |
visibleItemCount '5' | |
groovyScript choiceGroovyScript | |
bindings "jobName = JOB_NAME\nparameterName = DOCKER_TAG\ndefaultValue = latest" | |
defaultGroovyScript choiceGroovyScript | |
defaultBindings "jobName = JOB_NAME\nparameterName = DOCKER_TAG\ndefaultValue = latest" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment