Operations 5 min read

Using the Active Choices Plugin for Dynamic Parameterized Builds in Jenkins Pipelines

This guide explains how to install the Active Choices plugin in Jenkins and use Groovy scripts to create dynamic, parameterized build options such as checkboxes, radio buttons, and cascading selections within a Pipeline, including a complete Jenkinsfile example.

DevOps Cloud Academy
DevOps Cloud Academy
DevOps Cloud Academy
Using the Active Choices Plugin for Dynamic Parameterized Builds in Jenkins Pipelines

This article demonstrates how to add dynamic, user‑defined parameters to Jenkins pipelines by installing and configuring the Active Choices (Uno‑Choice) plugin.

First, navigate to Manage Jenkins → Manage Plugins → Available , search for “Active Choices Plugin”, install it, and restart Jenkins so the plugin appears under the “Installed” tab.

With the plugin installed, you can define parameters that generate their option lists at runtime using Groovy scripts or scripts stored in the Scriptler directory. These parameters can be rendered as checkboxes, radio buttons, or rich HTML UI widgets.

For a simple single‑select parameter, define a ChoiceParameter with a Groovy script that returns a list such as ['Dev','QA','Stage','Prod'] . The plugin will present these values in a dropdown.

For a cascading parameter, use CascadeChoiceParameter that references another parameter (e.g., Env ) and provides a script that returns different server lists based on the selected environment, using conditional if statements.

properties([
    parameters([
        [$class: 'ChoiceParameter', 
            choiceType: 'PT_SINGLE_SELECT', 
            description: 'Select the Env Name from the Dropdown List', 
            filterLength: 1, 
            filterable: true, 
            name: 'Env', 
            randomName: 'choice-parameter-5631314439613978', 
            script: [
                $class: 'GroovyScript', 
                fallbackScript: [classpath: [], sandbox: false, script: 'return[\'Could not get Env\']'], 
                script: [classpath: [], sandbox: false, script: 'return["Dev","QA","Stage","Prod"]']
            ]
        ], 
        [$class: 'CascadeChoiceParameter', 
            choiceType: 'PT_SINGLE_SELECT', 
            description: 'Select the Server from the Dropdown List', 
            filterLength: 1, 
            filterable: true, 
            name: 'Server', 
            randomName: 'choice-parameter-5631314456178619', 
            referencedParameters: 'Env', 
            script: [
                $class: 'GroovyScript', 
                fallbackScript: [classpath: [], sandbox: false, script: 'return[\'Could not get Environment from Env Param\']'], 
                script: [classpath: [], sandbox: false, script: '''
if (Env.equals("Dev")){
    return["devaaa001","devaaa002","devbbb001","devbbb002","devccc001","devccc002"]
}
else if(Env.equals("QA")){
    return["qaaaa001","qabbb002","qaccc003"]
}
else if(Env.equals("Stage")){
    return["staaa001","stbbb002","stccc003"]
}
else if(Env.equals("Prod")){
    return["praaa001","prbbb002","prccc003"]
}
'''
                ]
            ]
        ]
    ])
])

pipeline {
  environment {
         vari = ""
  }
  agent any
  stages {
      stage ("Example") {
        steps {
         script{
          echo 'Hello'
          echo "${params.Env}"
          echo "${params.Server}"
          if (params.Server.equals("Could not get Environment from Env Param")) {
              echo "Must be the first build after Pipeline deployment.  Aborting the build"
              currentBuild.result = 'ABORTED'
              return
          }
          echo "Crossed param validation"
        } }
      }
  }
}

The snippet above shows the full Jenkinsfile with the defined parameters and a simple stage that echoes the selected values and aborts the build if the server parameter could not be resolved.

Project and plugin references are provided for further exploration:

Project URL: https://github.com/jenkinsci/active-choices-plugin Plugin URL: https://plugins.jenkins.io/uno-choice/

The author, a DevOps practitioner, offers additional courses and resources on enterprise‑level DevOps operations and Linux administration.

CI/CDDevOpsPipelineGroovyJenkinsActive Choices
DevOps Cloud Academy
Written by

DevOps Cloud Academy

Exploring industry DevOps practices and technical expertise.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.