Skip to content

Instantly share code, notes, and snippets.

@visitbethel
Created February 2, 2017 17:58
Show Gist options
  • Save visitbethel/e4f7e8be66c67b69005bf45a01902c36 to your computer and use it in GitHub Desktop.
Save visitbethel/e4f7e8be66c67b69005bf45a01902c36 to your computer and use it in GitHub Desktop.
Jenkins Pipeline Input Dropdown
// Change `url` value to your own
def inputParams=new URL('http://maven.com/sefs/sefs-scm.txt').text
// Change `message` value to the message you want to display
// Change `description` value to the description you want
def selectedProperty = input( id: 'userInput', message: 'Choose properties file',
parameters: [ [
$class: 'ChoiceParameterDefinition',
choices: inputParams,
description: 'Properties',
name: 'prop'] ])
println "Property: $selectedProperty"
// Change `job` value to your downstream job name
// Change `name` value to the name you gave the string parameter in your downstream job
====> JAVA
https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/ChoiceParameterDefinition.java#L20
@DataBoundConstructor
public ChoiceParameterDefinition(String name, String choices, String description) {
super(name, description);
this.choices = Arrays.asList(choices.split(CHOICES_DELIMITER));
defaultValue = null;
}
@visitbethel
Copy link
Author

The input string must be one string with CRLF's to get things split out

"debug\nrelease\ndev",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment