I want to add a choice parameter to a Jenkins job. The list is fixed, but I want the dropbox to display custom value, and not the actual ones (analogous to name of a web page and not its URL).
In the certain case this is the path of the pom.xml
file, however, I want to display the module name instead of the full path. An example:
Actual value | What I want to be displayed
-------------------------------------|----------------------------
full/path/to/my/modules/pom.xml | All modules
full/path/to/my/modules/util/pom.xml | Utilities
full/path/to/my/modules/data/pom.xml | Data handling
Thanks for the help in advance!
You can do this with the Extended Choice Parameter plugin.
To set it the way you want, under "This build is parameterized", choose Extended Choice Parameter, and set it up like this:
Note it may look a little different depending on what version of Jenkins you have but it shouldn't be too different (this screenshot was on 2.0-beta-2).
With the Active Choices plugin, you can set this up with a groovy map:
Set a "Active Choices Parameter" with the following groovy script:
return['full/path/to/my/modules/pom.xml' : 'All modules',
'full/path/to/my/modules/util/pom.xml' : 'Utilities',
'full/path/to/my/modules/data/pom.xml' : 'Data handling']
The "value" of the map will be displayed in the build parameters choices:
And "key" of the map will be set in the variable:
> echo "$URL"
full/path/to/my/modules/pom.xml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With