### Jenkinsfile pipeline configuration
Source: https://plugins.jenkins.io/uno-choice
A Jenkinsfile demonstrating how to configure Active Choices and Cascade Choice parameters using Scriptler scripts.
```groovy
properties([
parameters([
[
$class: 'ChoiceParameter',
choiceType: 'PT_SINGLE_SELECT',
name: 'Environment',
script: [
$class: 'ScriptlerScript',
scriptlerScriptId:'Environments.groovy'
]
],
[
$class: 'CascadeChoiceParameter',
choiceType: 'PT_SINGLE_SELECT',
name: 'Host',
referencedParameters: 'Environment',
script: [
$class: 'ScriptlerScript',
scriptlerScriptId:'HostsInEnv.groovy',
parameters: [
[name:'Environment', value: '$Environment']
]
]
]
])
])
pipeline {
agent any
stages {
stage('Build') {
steps {
echo "${params.Environment}"
echo "${params.Host}"
}
}
}
}
```
--------------------------------
### Reactive Reference Groovy script generating formatted HTML for wine choices
Source: https://plugins.jenkins.io/uno-choice
This Groovy script uses a switch statement on the WINE_MENU variable to return formatted HTML with wine recommendations. It matches patterns using regular expressions and returns a bold recommendation string for each wine type.
```groovy
switch(WINE_MENU) {
case ~/.*Champagne.*/:
winerec='Champagne is perfect with anything salty'
return "${winerec}"
case ~/.*Sauvignon Blanc.*/:
winerec='Sauvignon Blanc goes with tart dressings and sauces'
return "${winerec}"
case ~/.*Grüner Veltliner.*/:
winerec='Choose Grüner Veltliner when a dish has lots of fresh herbs'
return "${winerec}"
case ~/.*Pinot Grigio.*/:
winerec='Pinot Grigio pairs well with light fish dishes'
return "${winerec}"
case ~/.*Chardonnay.*/:
winerec='Choose Chardonnay for fatty fish or fish in a rich sauce'
return "${winerec}"
case ~/.*Off-Dry Riesling.*/:
winerec='Off-Dry Riesling pairs with sweet & spicy dishes'
return "${winerec}"
case ~/.*Moscato dAsti.*/:
winerec='Moscato dAsti loves fruit desserts'
return "${winerec}"
case ~/.*dry Rosé.*/:
winerec='Pair a dry Rosé with rich, cheesy dishes'
return "${winerec}"
case ~/.*Pinot Noir.*/:
winerec='Pinot Noir is great for dishes with earthy flavors'
return "${winerec}"
}
```
--------------------------------
### Environments.groovy Scriptler script
Source: https://plugins.jenkins.io/uno-choice
A simple Scriptler script that returns a list of environment options for a choice parameter.
```groovy
return ["Select:selected", "DEV", "TEST", "STAGE", "PROD"]
```
--------------------------------
### HostsInEnv.groovy Scriptler script
Source: https://plugins.jenkins.io/uno-choice
A Scriptler script that dynamically returns a list of hosts based on the provided 'Environment' parameter.
```groovy
// Static content examples. These lists can be generated dynamically as an alternative.
List devList = ["Select:selected", "dev1", "dev2"]
List testList = ["Select:selected", "test1", "test2", "test3"]
List stageList = ["Select:selected", "stage1"]
List prodList = ["Select:selected", "prod1", "prod2", "prod3", "prod4"]
List default_item = ["None"]
if (Environment == 'DEV') {
return devList
} else if (Environment == 'TEST') {
return testList
} else if (Environment == 'STAGE') {
return stageList
} else if (Environment == 'PROD') {
return prodList
} else {
return default_item
}
```
--------------------------------
### Active Choices Parameter Script Return Value
Source: https://plugins.jenkins.io/uno-choice
The script must return a java.util.List, an Array, or a java.util.Map to dynamically generate parameter options.
```Groovy
return ['Option 1', 'Option 2', 'Option 3']
```
--------------------------------
### States Active Choices Parameter Script
Source: https://plugins.jenkins.io/uno-choice
Groovy script used to populate the 'States' parameter with a list of Brazilian states.
```Groovy
return [
'Sao Paulo',
'Rio de Janeiro',
'Parana',
'Acre'
]
```
--------------------------------
### Declare uno-choice as a Maven dependency
Source: https://plugins.jenkins.io/uno-choice/dependencies
Add this dependency block to your project's POM file to include the latest version of the Active Choices plugin.
```xml
org.biounouno-choice2.8.10
```
--------------------------------
### Groovy script returning HTML input element for reactive reference value
Source: https://plugins.jenkins.io/uno-choice
This Groovy script returns an HTML input element with a dynamic default value. It is used in scenarios where the reactive reference value should be passed to the build, either editable or hidden. The ReactiveRefParam variable holds the value to be passed.
```groovy
return ""
```
--------------------------------
### Cities Active Choices Reactive Parameter Script
Source: https://plugins.jenkins.io/uno-choice
Groovy script for the 'Cities' parameter that dynamically returns a list of cities based on the selected 'States' parameter value.
```Groovy
if (States == "Sao Paulo") {
return ["Barretos", "Sao Paulo", "Itu"]
} else if (States == "Rio de Janeiro") {
return ["Rio de Janeiro", "Mangaratiba"]
} else if (States == "Parana") {
return ["Curitiba", "Ponta Grossa"]
} else if (States == "Acre") {
return ["Rio Branco", "Acrelandia"]
} else {
return ["Unknown state"]
}
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.