Jenkins : Extensible Choice Parameter plugin

Plugin Information

View Extensible Choice Parameter on the plugin site for more information.

Older versions of this plugin may not be safe to use. Please review the following warnings before using an older version:

This plugin adds "Extensible Choice" as a build parameter.You can select how to retrieve choices, including the way to share choices among all jobs.

What's this?

This plugin provides a Extensible Choice parameter:

  • When building, the value can be selected with a dropdown like a built-in Choice parameter.
  • The choices can be provided in several ways:
    • Global Choice Parameter: defines choices in the Configure System page.
      • Choices can be shared by multiple jobs.
      • Updating the choices in the Configure System, every job can immediately refer the updated choices.
    • Textarea Choice Parameter: writes choices in a textarea, just like a built-in Choice parameter.
    • System Groovy Script Choice Parameter: runs a System Groovy script to determine the list of choices
    • File Choice Parameter: lists files in a directory.
  • Checking Editable checkbox allows you to specify any value, even one not in the choices.
    • Edited values can be added to the choice used next time automatically by checking "Add Edited Value".
  • You can add a new way to provide choices with Extension Points.

Disabling providers

Some choice providers may cause security issues in your system:

Choice Provider

Security Issue

Note

File Choice Parameter

Any users with project configuration privilege can list files in the OS with the privilege of the OS user Jenkins run with.

Users can do that also with "Execute shell" or "Execute Windows Batch" build step.

You can disable specific providers in system configuration page:

In the above screen, System Groovy Script Choice Parameter (unchecked one) is disabled.

Screenshots

  • "Extensible Choice" is added as a type of build parameters.
  • You can select the way to define choices of the parameter.
    ** A new way to provide choices can be added with Extension Points.
  • Selecting "Textarea Choice Parameter", you can define choices like the built-in Choice parameter.
  • "Global Choice Parameter" enables you to select a set of choices from the ones defined in System Configuration page.
    • Defining in System Configuration page:
    • Select which set of choices to use:
  • "System Groovy Choice Parameter" generate choices with a Groovy script:
  • "File Choice Parameter" enables select a file in a specified directory:
  • You can specify its default value. This is useful with Global Choice Parameter to specify different default values in jobs:
  • Checking "Editable" enables you to input a value not in choices at build time:
    ** Textarea Choice Parameter and Global Choice Parameter provides "Add Edited Value", which automatically adds a value not in the choice list:

Extension point

A new way to provide choices can be added with extending ChoiceListProvider, overriding the following method:

abstract public List<String> getChoiceList()

Issues

Open Issues

To report a bug or request an enhancement to this plugin please create a ticket in JIRA (you need to login or to sign up for an account). Also have a look on How to report an issue

 

Change Log

Version 1.6.0 (May 20, 2018)

  • Add an option to switch the behavior of input value when the input is editable (JENKINS-22316, JENKINS-50315)
    • You can select "Display all choices" (the behavior same to Extensible Choice Paramter <= 1.4.2) or "Display only matching choices" (the behavior same to Extensible Choice Paramter 1.5.0).
    • "Display all choices" is the default behavior.

Version 1.5.0 (Mar 17, 2018)

Version 1.4.2 (Jan 27, 2018)

Version 1.4.1 (Aug 27, 2017)

Version 1.4.0 (Apr 10, 2017)

  • SECURITY FIX: Jenkins Security Advisory 2017-04-10#Extensible Choice Parameter Plugin
    • Groovy scripts run with Script Security Plugin
    • Existing scripts are configured to run in the script sandbox.
    • You might require approve some methods for the sandbox, or configure scripts run without the sandbox and approve scripts.
  • Targets Jenkins >= 1.580.1.
  • The pre-defined variable 'jenkins' is no longer provided.
    • You can get Jenkins instance with jenkins.model.Jenkins.instance instead. Require appropriate approving.

Version 1.3.4 (Jan 28, 2017)

  • Use the top most value if the specified default parameter isn't contained in the choice list.
    • Note: Builds fail if you passed a value not contained in the choice list explicitly (e.g. via Parameterized trigger plugin).

Version 1.3.3 (Oct 22, 2016)

  • FIXED: "Top Most Value" is replaced with an empty value when saved before the job configuration page is completed to be load (JENKINS-37147)

Version 1.3.2 (Aug 23, 2015)

  • Fixed UnsupportedOperationException when Empty Choice is configured for File Choice Parameter (JENKINS-29934)
  • Improved the help of Exclude Pattern of File Choice Parameter.

Version 1.3.1 (Jun 20, 2015)

  • Fixed NPE with "List Files Now" in configuration pages (JENKINS-28841, regression in 1.3.0)

Version 1.3.0 (May 05, 2015)

  • Now you can disable specific providers in system configuration page (JENKINS-27375).
  • Validates parameter names by checking they can be handled by Jenkins core (JENKINS-22222).
  • Fixed "Error: No stapler-class is specified" when saving project configuation with Jenkins 1.610(JENKINS-28046).
    • Dot letters are allowed for variable names with Jenkins > 1.526.
  • Added an empty choice option to FilenameChoiceListProvider (JENKINS-22318).
  • Also accepts $class introduced in Jenkins 1.588 (JENKINS-25403).

Version 1.2.2 (Dec 08, 2013)

  • Added feature to use project in System Groovy Script. JENKINS-17875
  • Added feature to reverse file lists.

Version 1.2.1 (Jun 22, 2013)

  • Added documents for System Groovy Script Choice Parameter.
  • Added "Run the Script Now" Button for System Groovy Script Choice Parameter.

Version 1.2.0 (May 03, 2013)

  • Added new providers
    • System Groovy Script Choice Parameter: runs a System Groovy script to determine the list of choices
    • File Choice Parameter: lists files in a directory.
  • Added checkbox "Add Edited Value" to Textarea Choice Parameter and Global Choice Parameter. By checking this, edited values used in builds are automatically added to choices.

Version 1.1.0 (Feb 06, 2013)

  • Now you can select the default choice in each job.
  • Fixed the misspell.

Version 1.0.0 (Jan 07, 2013)

  • Initial release.

Attachments: