Due to some maintenance issues, this service has been switched in read-only mode, you can find more information about the why

and how to migrate your plugin documentation in this blogpost

Skip to end of metadata
Go to start of metadata

Plugin Information

Distribution of this plugin has been suspended due to unresolved security vulnerabilities, see below.

The current version of this plugin may not be safe to use. Please review the following warnings before use:

This plugin allows dynamic generation of default build parameter values.


What Does the Plugin Do?

The plugin allows creating a build parameters, which default value(s) are generated by a Groovy script. The Groovy script is executed each time the build is triggered and allows generating default value(s) according to the current build context (e.g. current user-name, current date/time, etc. or more complex Groovy scripts). The Groovy script can be executed either on the master or on the slave where the build is executed. This can be configured from the build configuration page.

The plugin provides two types of parameters: simple text-field parameter and a choice (drop-down) parameter. If the parameter is a text-field, the corresponding Groovy script must return a single string value. If the parameter is a choice parameter, then the script must return a list of string values.

Current Date and Time

This is a simple example shows how to create a build parameter which has the current date and time. Create a new build job and choose "This build is parameterized". From the "Add Parameter" drop-down menu, choose "Dynamic Parameter".

Fill in the parameter "Name" and optional "Description". In the field "Default Value Script" write the Groovy script which returns the current date:

Note: if the "Remote Script" check-box is checked, then the script will be executed on the slave where the build is started.

Save the current job and click "Build Now". The build configuration page with the current date and time should show up:

Simple Choice List

This is a simple example which shows how to create a choice parameter. Similar to the previous example, create a new build job and choose "This build is parameterized". From the "Add Parameter" drop-down menu, choose "Dynamic Choice Parameter". Fill in the parameter "Name" and optional "Description". In the field "Choices Script" write the Groovy script which returns a list with some values:

Save the current job and click "Build Now". The build configuration page with a drop-down to choose from one of the generated values should show up:

Version History

0.1.1 (Apr 03, 2012)
  • Safe use of anonymous classes
  • Fixes in POM to allow release with maven release plugin
0.1.0 (Mar 20, 2012)
  • Initial release


  1. Unknown User (bakito)


    I want to add a choice parameter to choose a subdirectory in my workspace by using the following script:

    Arrays.asList(new File("/absolute/path/to/my/workspace").list())

    Is there a way to use the env variables from jenkins to get a script without absolute paths?

    Something like:

    Arrays.asList(new File("$WORKSPACE").list())
  2. Unknown User (lrli)

    If "Remote script" is unchecked, it runs on the master, but does it run in a forked JVM? For example:

    On the plugin, this returns nothing.
    def list = hudson.model.Hudson.instance.getLabelAtoms()

    On http://

    Unknown macro: {JENKINS}

    /script, this returns the list of labels.

  3. Unknown User (cecom)


    i would like to use this plugin to fill a drop-down list with commands, depended on the logged in user. Here the code:

    def result = ["-------"]
    def auth=Jenkins.instance.getAuthentication()
    if ( auth == null ) return result
    def userId=auth.getName()
    if ( userId == null ) return result
    def confFileName = userId.replace("\\","_");
    def confFile = new File("/srv/jenkins/conf/jenkins/task/" + confFileName)
    if (! confFile.exists())  return result
    return result

    If i execute it in the jenkins script console i get the desired result. But within your plugin, i dont get the entries. What do i miss?

    1. Unknown User (cecom)

      got it. jenkins.model isnt imported by default. so replace:

      def auth=Jenkins.instance.getAuthentication()
      def auth=jenkins.model.Jenkins.instance.getAuthentication()

      and it works. Nice (smile)

      1. Unknown User (wernight)

        Thanks to you I could create a custom list of runs to select from:

        return jenkins.model.Jenkins.instance.getJob('MyJobName').builds.findAll{
          it.result == hudson.model.Result.SUCCESS || it.result == hudson.model.Result.UNSTABLE
          def env = it.getEnvironment()
          "#$it.number - v$env.RELEASE_VERSION [$env.GIT_BRANCH]"

        Note that I'm then using EnvInject Plugin to keep only the build number from the selected string.

  4. Unknown User (oddityoverseer13)

    I need some help with this plugin. I want to make a dynamic choose parameter who's options are the output of a bash command. For example, if I run 'ls -1' and get:


    Then each of those should be an option in the choose list. I can't get this to work at all. Can someone tell me what code would do that?

    My most recent attempt looks like this:

    def command = """ls -1"""
    def proc = command.execute()
    Thread.start { System.err << proc.err }
    return proc.in.text


    1. Unknown User (potmo)

      Having a smililar problem as you have but with "gsutil ls". the proc.waitFor() does not work at all. 

      If you want to do the "ls" stuff do this instead. it works:

      ls="ls -t1 /some/folder/of/interest/".execute().text
      def list=ls.readLines()

      I really would like to do a gsutil ls that takes some time but it seems that it is impossible to hava a slow blocking call.

      Anyone knows a workaround?

      1. Unknown User (shakenfr)

        hi, I use your solution and it works, but have you a solution for my use.

        Explication : I use a dynamic parameter called TARGET where I put your code. When I launch my build it works.

        Now I want to introduce in the same job another param based on the selection of TARGET to do another ls inside the first one.

        I have tree like this :





        On TARGET variable, with your groovy script I select inventory1 or inventory2

        than I would like to select the correct list in a combo box of a second variable based on the first one (LIMIT variable)

        if a select TARGET=inventory1

        I want a possible selection (LIMIT) to 1st_server_lists or 2nd_list_servers  if I choose TARGET as inventory1  and LIMIT=1st_server_lists if I choose inventory2.

        I want to use the value of TARGET variable to use in a second variable BEFORE the build.

        Any idea ?



    2. Unknown User (ksylvan)

      I have a similar need. I've been trying to populate the dynamic choice with a set of directory names in the $WORKSPACE

      but can't get this to work. Any help is appreciated!

      1. Unknown User (ksylvan)

        I ended up getting around my issue by having another job create the lists of choices and put them in files, then I do this for a dynamic choice (with the "Remote script" check-box checked).

        choices_job_dir = "/var/hudson-slave/workspace/choice_update/"
        def file = new File(choices_job_dir + "dev.list")
        if (! file.exists()) {
          list = [ "=== PLEASE RUN THE choice_update JOB to generate the list here ===" ]
        } else {
          list = file.readLines()
        1. Unknown User (idomic)

          hey im having the same problem as you,

          I have a file with lines which i want it to be a choice parameter but it's on different machines,

          how did you handled it?

  5. Unknown User (rameshpasham)

    Hi All,

    It is nice plugin to provide dynamic values at triggering the build.

    But my usage is little bit different. I want to give dynamic values based on the input(another predefined parameter) of the user.

    is it possible with this plugin or is there any option to solve this requirement.

    1. Unknown User (mconlon)

      I'd also love to see this feature!

  6. Unknown User (billwonch)

    Hi -

    Sorry to add this here, and not to the JIRA tickets, but I couldn't find this plugin listed in components...

    So under version 0.1.1, I could do this:

    new Date().format( 'yyyyMMdd' ) and get the date in the proper format.

    Once I upgrade to version 0.2.0, this no longer works.  Is this a bug, or have I messed up the formatting somehow?


  7. Unknown User (rameshpasham)

    Hi dimitarp,

    I am not able to view the source code of you on GIthub.

  8. Unknown User (mconlon)

    This plugin doesn't seem to have any JIRA component associated with it, so I will make a feature request here:

    Currently this plugin only supports a Dynamic String Parameter (one line of text). My request would be to allow for a Dynamic Text Parameter (multiple lines of text).

  9. Unknown User (steverdavidson)

    in the choices script for this probe, how can I debug?  I need to figure out why a variable that I expect has a value, doesn't behave as if it does.  I tried

     println ${var}

    but can't find any output anywhere.  I appreciate any help you can offer.

  10. Unknown User (eeeanoop)

    Nice plugin. Is it possible to trigger a script say ~/dynamic_choice_generator.groovy from the 'Choices Script' text area?

    1. Unknown User (exelerus)

      You are able to run external scripts in the plugin by using evaluate:

      return evaluate(new File('/opt/jenkins/myjenkinsscripts/dynamic_choice_generator.groovy'));

  11. Unknown User (tmoore)

    It would be really useful if this plugin allowed access to information about the current job.  This is a capability that was added to V1.2.2 of the extensible-choice-parameter-plugin as referenced in JENKINS-17875, but that plugin is for choice parameters.

  12. Unknown User (albin0)

    Good morning. I'm trying to execute a job una a slave windows machine which has the groovy folder but it isn't in the path. I would know if is it possible to run the dynamic choice parameter using the groovy folder in my slave.

    In the Groovy build step it is possible by setting in jenkins configuration the path of the groovy folder in my windows machine and after choosing which groovy to use. So the dynamic choice parameter wich version of my GROOVY_HOME is using?

    I have also another question. What's the utility of the field "Class Paths" ?

    Thank you.

  13. Unknown User (idomic)

    Hey I want to specify a machine for the groovy to run

    or collect a txt file from a different slave, is it possible?

  14. Unknown User (nickg)

    Getting Global Environment Variables:

    String[] envVars = jenkins.model.Jenkins.getInstance().getGlobalNodeProperties().toMap().collectMany{it.value.getEnvVars().collect{"$it.key=$it.value"}}
  15. Unknown User (fsteff)

    Use groovy script list files at a specific location, and reverse sort them 

    // Create list of zip files, newest first
    new File( 'c:/FileServer/Bootloader_Releases' ).list()
                      .findAll { it.endsWith( '.zip' ) }
    //Option to remove extension:
    //                  .collect { it[ 0..-5 ] }


  16. Unknown User (keshlam)

    Is there a reason this was never integrated with the Secure Scripting plug-in, to resolve the Arbitrary Code Execution issue? There are still cases where we'd like to use it but have been told we Really Shouldn't... If there isn't a reason it can't be done, How Hard Would It Be to get a proposed patch accepted?

    (Yes, Extended Choice Parameters can be shoehorned into doing some of the same things, and already support Secure Scripting. However, their text box mode is too narrow to handle longer text – paths, eg – very well. The question is whether it'd be easier to fix that or fix this, and how much pushback to expect either way.)