Skip to end of metadata
Go to start of metadata

Plugin Information

View Active Choices 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:

The Active Choices plugin allows the creation of dynamic and interactive parameters for freestyle Jenkins jobs. Active Choice parameters can be dynamically updated and can be rendered as combo-boxes, check-boxes, radio-buttons or rich HTML.

Active Choices will load two extra Javascript files, JQuery and unochoice.js. Starting with v2.0 the plugin is again available in the Jenkins update center.

Starting with Active Choices v2.0, sandboxed Groovy scripts for Active Choices Reactive Reference Parameter will no longer emit HTML that is considered unsafe, such as <script> tags. This may result in behavior changes on Build With Parameters forms, such as missing elements. To resolve this issue, Groovy scripts emitting HTML will need to be configured to run outside the script security sandbox, possibly requiring separate administrator approval in In-Process Script Approval.

Earlier versions can be installed manually. Read this https://groups.google.com/forum/#!topic/biouno-users/Y7RfkOvizZ8 and download the plugin manually from: https://repo.jenkins-ci.org/releases/org/biouno/uno-choice/

Before filing issues, please take a look at the Troubleshooting Page

Overview

The Active Choices plug-in provides additional Jenkins parameter types that can be rendered as user interface (UI) controls in job forms. It supports using system environment variables, global node properties, and you also have at least the Jenkins project in the Groovy context for Freestyle jobs at least.

Once the plugin is installed three new parameter types become available:

  1. Active Choices Parameter
  2. Active Choices Reactive Parameter
  3. Active Choices Reactive Reference Parameter

Active Choices parameters allow users to select value(s) for a job parameter. Parameter values can be:

  • dynamically generated (using Groovy or a Scriptler script)
  • dynamically updated based on other UI parameters
  • multi-valued (can have more than one value)
  • rendered with a variety of UI controls, including dynamic HTML

We will introduce the Active Choices based UI controls by briefly describing their behavior and rendering characteristics. We will then provide a guide to their configuration

Active Choices Parameter

Behavior

  • An Active Choices parameter dynamically generates a list of value options for a build parameter using a Groovy script or a  script from the Scriptler catalog.

Rendering

  • Active Choices parameters can be rendered as standard selection lists, check boxes and radio buttons.
  • A text box filter can be optionally shown to aid in filtering the value options.

Active Choices Reactive and Reactive Reference Parameters

Both of these parameters have additional useful behaviors and Reactive Reference has some unique rendering options.

Behavior

Similarly to Active Choices Parameter above:

  • Active Choices Reactive and Reactive Reference parameters dynamically generate value options for a build parameter using a Groovy script or a Scriptler script

In addition:

  • Active Choices Reactive and Reactive Reference parameters can be dynamically updated (cascade update) when the value of other job UI control(s) change(s)

Rendering Options

Active Choices Reactive

  • Active Choices Reactive parameters can be rendered as standard selection lists, check boxes and radio buttons.
  • A text box filter can be optionally shown to aid in filtering the value options.

Active Choices Reactive Reference

Active Choices Reactive Reference parameters are used to enhance a Jenkins job form UI with reference information.

With this use case in mind, a Reactive Reference UI control can be rendered as:

  • An HTML list (bulleted or numbered)
  • An HTML input text box
  • Dynamically generated HTML (image, iframe, etc.);

The dynamically generated HTML option, works with any well-formatted HTML returned by the Groovy script.It enables rendering of a variety of HTML elements, including pictures, inline-frames, hyperlinks, richly formatted text etc.

In addition, Reactive Reference parameters can be hidden from the UI and thus provide the option of dynamically generating hidden build parameters. These options are further discussed in the Reactive Reference configuration section.

Rendering Example

In the example above the value options for the 'Professions' parameter get updated when the 'Gender' parameter changes.

In addition, the Reactive Reference parameter 'Gender_Balance' rendered as a picture is also dynamically updated when the 'Gender' parameter is updated.

Behavior and Rendering Summary

The following table summarizes the behavior and rendering characteristics of the three Active Choices parameter types.

Active Choices Parameter Type Configuration

The following parameters are included in the plug-in:

  • Active Choices Parameter
  • Active Choices Reactive Parameter
  • Active Choices Reactive Reference Parameter

We now describe the details of their configuration.

Active Choices Parameter: Configuration Options (Example 01)

An Active Choices Parameter is configured by setting the following options in the parameter configuration

The 'Name' and 'Description'

These are the typical parameter Name and Description that are common to all Jenkins parameters

The 'Script'

The 'Script' is the Groovy code or Scriptlet script that will dynamically generate the parameter value options

  • By selecting either of the two radio button options you can either type a Groovy script directly or use a Scriptler script
  • The script must return a java.util.List, an Array or a java.util.Map, as in the example below:

    return ['Option 1', 'Option 2', 'Option 3']

The 'Fallback Script'

The 'Fallback Script' configuration option provides alternate parameter value options in case the main Script fails either by throwing an Exception, or by not return a java.util.List, Array or java.util.Map.

The 'Choice Type'

The 'Choice Type' option provides four different rendering options for the option values:

  1. A list box where a single selection is allowed
  2. A list box where multiple selections are allowed
  3. A list of check boxes (multiple selections allowed)
  4. A list of radio buttons (a single selection is allowed)

The 'Enable Filter'

The 'Enable Filter' option will provide a text box filter in the UI control where a text filter can be typed. Only value options that contain the text are then listed.

This filer is case independent.

Active Choice Parameter Rendering (Example 01)

The Example 01 Active Choice parameter configuration generates the following build form UI control. The user can select a single 'State' option from a filterable drop down list.

Making 'Default' selections

It is possible to have some of the options displayed in an Active Choices UI control selected by default when the control is initialized.

You can define the default value selections by adding the suffix; :selected to the element you want to be the default selection from those returned by the script.
In the example below, we will make the State of 'Parana' the default selection when the parameter UI control is rendered.

We credit the developers of the Dynamic Parameter plugin with some of the initial concepts and code on which Active Choices was implemented. However, there are several important differences and improvements between the  Active Choices plugin and the original Dynamic Parameter plugin:

  1. An Active Choices parameter can be rendered as a multi-select control (combo-box or check-box) allowing users to select more than one value for the parameter 
  2. The parameter options value list can be filtered. If the "Enable Filters" option is checked, an extra input box will be displayed allowing users to filter the options.
  3. You can define a 'fallback' behavior if the value generator script raises an exception.
  4. You can define default value selections in the dynamically generated value list

Active Choices Reactive Parameter: Configuration Options (Example 02)

An Active Choices Reactive parameter is configured with a set of similar options as those shown above for the Active Choices parameter. However, a Reactive parameter provides the additional 'Referenced parameters' configuration option.

  • This option, takes a list of job parameters that trigger an auto-refresh of the Reactive Parameter when any of the 'Referenced parameters' change

The 'Referenced parameters'

The 'Referenced parameters' text field contains a list of comma separated parameter Names (from the current job) that will trigger a refresh of the Reactive Parameter when their values change. The values of these parameters are passed to the script binding context before the script is re-executed to generate a new set of option values for the Active Choices control. 

Active Choices Reactive Parameter Rendering (Example 02)

Let's examine a Jenkins build form rendered with Active Choice parameters that satisfies the following requirements. The form:

  • Allows users to select one of several Brazilian States
  • Provides an additional control where a set of Cities belonging to the selected State is dynamically displayed
  • Allows the user to select one or more of the displayed Cities

The job UI is composed of two parameters:

1) States: An Active Choice Parameter

The first parameter is the States Active Choice Parameter from Example 01. It allows the user to select one of several Brazilian States.
We could have just as easily used a Jenkins Choice Parameter, but we use an Active Choice parameter (as shown from Example 01). The Groovy script for this is:

return[
'Sao Paulo',
'Rio de Janeiro',
'Parana',
'Acre'
]

2) Cities: An Active Choices Reactive Parameter

The second parameter is the Cities Active Choices Reactive Parameter that dynamically displays a set of cities belonging to the selected State and allows users to select multiple values. The Cities parameter configuration is shown above in Example 02.

Note that:

  • The Cities Reactive parameter references the previously defined States parameter ('Referenced parameters'=States);
  • The 'Choice Type' is set to Check Boxes.This will allow the user to select one or more Cities by selecting multiple check boxes.
  • A custom 'Groovy Script' will be used to generate the Cities value options as shown below (the last list value returned by the script)
if (States.equals("Sao Paulo")) {
  return ["Barretos", "Sao Paulo", "Itu"]
} else if (States.equals("Rio de Janeiro")) {
  return ["Rio de Janeiro", "Mangaratiba"]
} else if (States.equals("Parana")) {
  return ["Curitiba", "Ponta Grossa"]
} else if (States.equals("Acre")) {
  return ["Rio Branco", "Acrelandia"]
} else {
  return ["Unknown state"]
}

Whenever the user changes the option of the States parameter, the Cities parameter will get dynamically updated. Note how that the States referenced parameter is in the script binding and can be used directly.

You can use a Reactive parameter type for things like displaying the list of Maven artifacts, given a group ID.

Active Choices Reactive Reference Parameter: Configuration Options

A Reactive Reference parameter is configured with a set of similar options as those shown above for the Active Choices Reactive parameter.

However, a Reactive Reference parameter provides a unique set of rendering options (see 'Choice Type').

  • Input text box
  • Numbered list
  • Bullet items list
  • Formatted HTML
  • Formatted Hidden HTML

Given the wide variety of rendering options the Active Choices Groovy script must return the following types of variables for each option:

Choice Type

Groovy Returns

Comment

Input text box

String

The return String appears in a simple text box

Numbered list

List

The return List displays as a numbered list

Bullet items list

List

The return List displays as a bulleted list

Formatted HTML

String

The return String must be well formatted HTML to display correctly. You can include any HTML tags here, e.g.: some <table>, or a <form> to another web site.

Formatted Hidden HTM

String

The parameter won't be displayed in the UI

A typical application of a Reactive Reference parameter is to dynamically display reference information that can be used to guide the user in making an appropriate value selection of another job parameter.

By design, the values of Reactive Reference parameters are NOT passed to the build environment with one important exception. When the choice type is set to Formatted HTML or Formatted Hidden HTML and the HTML is an 'input' element the value can be passed to the build. See the 'Advanced Usage' section for additional instructions.

Example Configuration: Active Choices Reactive Reference Parameter

Below we present 3 examples of Reactive References with different Choice Types and their corresponding renderings in the Jenkins job UI.

Consider an example where the user needs to make a meal selection that complements the available wine selection. The food selection would be easier if some useful reference info could be offered when users considered a particular wine. We call this reference information the WINE_RULE and we can easily implement it using a Reactive Reference parameter.

The WINE_RULE gets automatically updated when a user makes a new selection from the WINE_MENU (Note Referenced parameters=WINE_MENU). As a result, when we make a WINE_MENU selection we also get a WINE_RULE that can guide the FOOD_MENU selection.

Reactive Reference Configuration (Example 03)

The complete configuration of the WINE_RULE parameter is shown below.

Reactive Reference Groovy script (Example 03)

The groovy script that generates the WINE_RULE formatted HTML for each of the choices is shown below.

switch(WINE_MENU){
 case~/.*Champagne.*/:
	winerec='Champagne is perfect with anything salty'
	return "<b>${winerec}</b>"
 break
case ~/.*Sauvignon Blanc.*/:
	winerec='Sauvignon Blanc goes with tart dressings and sauces'
	return "<b>${winerec}</b>"
break
 case~/.*Grüner Veltliner.*/:
	winerec='Choose Grüner Veltliner when a dish has lots of fresh herbs'
	return "<b>${winerec}</b>"
 break
case~/.*Pinot Grigio.*/:
	winerec='Pinot Grigio pairs well with light fish dishes'
	return "<b>${winerec}</b>"
 break
case ~/.*Chardonnay.*/:
	winerec='Choose Chardonnay for fatty fish or fish in a rich sauce'
	return "<b>${winerec}</b>"
break
 case~/.*Off-Dry Riesling.*/:
	winerec='Off-Dry Riesling pairs with sweet & spicy dishes'
	return "<b>${winerec}</b>"
 break
 case~/.*Moscato dAsti.*/:
	winerec='Moscato dAsti loves fruit desserts'
	return "<b>${winerec}</b>"
 break
case ~/.*dry Rosé.*/:
	winerec='Pair a dry Rosé with rich, cheesy dishes'
	return "<b>${winerec}</b>"
break
 case~/.*Pinot Noir.*/:
	winerec='Pinot Noir is great for dishes with earthy flavors'
	return "<b>${winerec}</b>"
 break
}

Advanced Usage Notes

Considerations while writing your Groovy script

Your Groovy script binding has access to two additional variables for use:

  • jenkinsProject -> The Jenkins Project object
  • jenkinsBuild -> The Jenkins Build object

Passing Reactive Reference Values to the build

As was mentioned earlier, in general the values of reactive reference parameters are not passed to the build. However, there are some scenarios where the ability to pass these values would be of interest. For a more extensive discussion of this feature you can read here.

Scenario 1: Pass a dynamically created value that can be edited by the user

In this scenario, we want to provide the user a dynamic default value that is also editable. This can be accomplished with the following reactive reference configuration:

  • Choice Type: Formatted HTML
  • Groovy Script returning an HTML input element with the dynamic default value
  • Advanced Option set to

Scenario 2: Pass a dynamically created value that is hidden (can't be edited by the user)

In this scenario, we want the build to have access to a dynamic parameter generated from user input/option selections in the UI. The parameter is created programmatically, and is not user-editable. This can be accomplished with the following reactive reference configuration:

  • Choice Type: Formatted Hidden HTML
  • Groovy Script returning an HTML input element with the dynamic default value
  • Advanced Option set to

    A 'Formatted Hidden HTML' Choice type is useful when you want to calculate values to use in the build, but these values should not be modified by the user(e.g. to compute the deploy URL).

    In both scenarios the groovy script must return an HTML element formatted as follows:

    return "<input name=\"value\" value=\"${ReactiveRefParam}\" class=\"setting-input\" type=\"text\">"
    

    ReactiveRefParam is the Reactive Reference value that will be passed to the build

Scenario 3: Create an input control with dynamic HTML and pass its value to the build

This is an interesting application of the Reactive Reference parameter. It allows you to create custom UI parameter controls with improved interactivity. See example

Advanced Option: Omit Value Field

By default Reactive References pass to the build a hidden <input name="value" value="">. It means that your Reactive Reference parameter will always be empty, but you can use a Formatted HTML parameter and instruct the plug-in to not include this hidden value parameter.

You can click the Advanced button and there you will find an option to omit the value field. This will you let you define a value for the hidden parameter.

Using Active Choices with Scriptler scripts

We assume users that need to use Scriptler generated parameters are already familiar with the Scriptler Plug-in. If you need further information on how to use the Scriptler Plug-in, please refer to its Wiki page first.

Similarly to a Groovy script, a Scriptler script is also written in Groovy and used to render the parameter. Your Scriptler script is also expected to return a java.util.List, Array or java.util.Map for Active Choices and Reactive parameters, or custom HTML elements for the Reactive Reference parameter. Note that the value of other build parameters (when using Scriptler in combination with Active Choices) will be available in the Scriptler script context. You do not need to define such parameters in the Scriptler interface, or during the job definition. 

However, the main advantage that the Scriptler Plug-in provides is the creation of a reusable Groovy script catalog that can be used across multiple jobs or even for automation.

To make your Scriptler scripts reusable across multiple projects you should parameterize them and assign script parameters using build parameters.

TODO: Provide an example

Filter Supports Regular Expressions

Note that although the text 'Filter' box available for Active Choices parameters provides easy, case insensitive filtering by simply typing some text, it also support more sophisticated filtering using regular expressions.

The following example shows such an example where a complex options list is filtered using a regular expression.

Languages Supported

  1. English
  2. Portuguese (Brazil)) Work in Progress
  3. If you want to include yours, send us a pull request with the messages.properties files or get in touch!

Known Limitations

  1. - The parameters are supposed to be handled only by humans, and at the moment do not work when the job is triggered by plug-ins, API or scripts. Please see this issue for more.

Compatibility Matrix

This plug-in is not developed for Hudson, and we don't fix bugs happening in any version of Hudson.

Plugin

1.0

1.1

1.2

Jenkins

1.580.1+

1.580.1+

1.580.1+

Open Issues

Sponsors

For commercial support, please get contact us via @tupilabs

BioUno

Resources

URL

Description

http://biouno.org/publications.html 

Contains a list of resources for several plug-ins created in the BioUno project, including Active Choices, R, and Image Gallery.

https://www.cloudbees.com/event/topic/jenkins-ci-open-source-continuous-integration-system-scientific-data-and-image

In Ioannis Moutsatsos' talk, you can find slides about the Active Choices (née Uno-Choice) plug-in, as well as watch it being used too.

Release Notes

Version 2.1 (2018/01/01)
  1. JENKINS-48230: Discover parameters on jobs' wrappers 
  2. JENKINS-47908: After upgrade to v2.0, the active choices updates randomly in the browser 
  3. JENKINS-48448: Add a variable with the parameter name
  4. JENKINS-43380: Input parameter HTML description not working 
Version 2.0 (2017/10/23)
  1. Fix security vulnerability
    1. Important: Sandboxed Groovy scripts for Active Choices Reactive Reference Parameter will no longer emit HTML that is considered unsafe, such as <script> tags. This may result in behavior changes on Build With Parameters forms, such as missing elements. To resolve this issue, Groovy scripts emitting HTML will need to be configured to run outside the script security sandbox, possibly requiring separate administrator approval in In-Process Script Approval.

  2. JENKINS-42685: Remove custom stapler proxy as we can now use assync requests
  3. JENKINS-31625: Add configuration parameter, which defines, when filter must started work
  4. JENKINS-36158: Active choice reactive reference parameter not working on checkbox reference 
  5. JENKINS-43380: Input parameter HTML description not working 
  6. Pull request #15: Make Scriptler dependency optional (thanks to Daniel Beck)
Version 1.5.3 (2017/03/11)
  1. JENKINS-34487: Do not hang the browser when parameter re-evaluated (thanks to Vladimir Fedorov)
  2. JENKINS-38532: Active Choices Reactive Reference Parameters don't parse equals character ('=') properly.
  3. JENKINS-34188: jenkins.log noise: "script parameter ... is not an instance of Java.util.Map."
Version 1.5.2 (2016/11/16)
  1. JENKINS-39620: Saving a job with Active Choice 1.4 parameters after upgrade to v1.5 resets scriptlet parameters
  2. JENKINS-39760: Active Choices Parameters lost of Job Config save
Version 1.5.1 (2016/11/11)
  1. JENKINS-36590: Active-Choice jenkinsProject variable is not available under Folder or Multibranch-Multiconfiguration job
  2. JENKINS-37027: 'View selected script option' in build configuration displays wrong scriptler script
  3. JENKINS-34988: this.binding.jenkinsProject not returning project of current build
  4. Upgraded build plug-ins
  5. Fixed Findbugs issues
  6. Upgraded parent in order to be able to release to Jenkins plug-in repositories
  7. JENKINS-39620: Saving a job with Active Choice 1.4 parameters after upgrade to v1.5 resets scriptlet parameters
  8. JENKINS-39534: When Jenkins restarts, the groovy scripts are lost
  9. JENKINS-34818: Active Choice reactive parameter cannot access global parameters
Version 1.5.0 (2016/11/04)
  1. Removed from the update center. Read more about it here
Version 1.4 (2016/02/14)
  1. JENKINS-32405: Groovy script failed to run if build started by timer
  2. JENKINS-32461: jenkinsProject variable is not available in Multi-configuration project
  3. JENKINS-32566: Render an AC Reactive reference as a functional Jenkins File Parameter
Version 1.3 (2015/12/24)
  1. pull-request/6: Let "PhantomJS Unit Testing" be able to run on both linux and windows...
  2. JENKINS-30824: Active Choice Reactive Parameter - radios button value not passed to build (thanks to lyen liang for his PR showing how to fix it
  3. JENKINS-32044: Fail to evaluate Boolean parameter to "on" when checked
  4. JENKINS-30592: An AC Reactive Reference is always displayed unless it references a parameter
  5. JENKINS-32149: Create random parameter name only once
  6. JENKINS-29476: The 'jenkinsProject' variable is not set in the binding after restarting Jenkins (thanks to @perfhector for PR/5)
Version 1.2 (2015/07/22)
  1. pull-request/1: Use value of Reactive Reference dynamic input controls as build parameters. See example
  2. pull-request/2: Update unochoice.js
Version 1.1 (2015/06/28)
  1. JENKINS-29055: Problem with Active Choices 1.0 and jQuery
  2. JENKINS-28764: Environment variables are not expanded and thus cannot be used as parameter values to Scriptler scripts
  3. JENKINS-28785: Referenced Parameters Not Passed to Scriptler Scripts
Version 1.0 (2015/06/03)
  1. Initial release to Jenkins update center, with Choice, Cascade Dynamic Choice and Dynamic Reference parameter types.
Versions released to BioUno update center

The first commit happened on 2014/03/13, and the initial release on 2014/03/21. There were 24 releases to the BioUno update center, the last one being on 2015/03/26, when the project decided to publish it via Jenkins update center.

Roadmap (wish list)

Version 1.x
  1.  Bug fixes based on user's feedback, and more unit tests.

152 Comments

  1. pardon the crazy question...

    can someone inform how I download and install this plug-in?  It's not listed in my jenkins plug-in section.  Any insight is greatly appreciated.

    1. No crazy question at all mac taylor.

      The plug-in (née Uno-Choice from the BioUno project) hasn't been released yet. We recently got the plug-in approved an cloned under the jenkinsci repo.

      Next step is send an e-mail to the biouno-dev-list to get people to help testing to make sure that the migration will work smoothly.

      If you want to see this plug-in released soon, testing the 0.24 version from BioUno and installing the Active Choices 0.1-SNAPSHOT would be of great help. If you find any errors, we can fix them before releasing 1.0. The release process will take no more than 1 day, and I can do that any day of the week/end. However, Ioannis is the person with more skill on how to use and test the plug-in. We also depend of his +1 to release it.

      Hope that helps, feel free to drop this kind of questions to the Jenkins User List (I'm not notified of comments here)

  2. Ohhhhh boy I have been waiting for this!!!!! We internally use jenkins for all kinds of adhoc automation tasks and the lack of chained parameters was a pita. 

    Just added the plugin and took it for a test drive, so far is working as advertised. 

    You guys just made my day . . .

    A big thanks goes out to all that contributed to this !

    Cheers,

    - Matthew

    1. Glad you found this plugin useful too Matthew! All of my Jenkins projects are adhoc analytics application (using a heavy dose of the R plugin).
      I could not have done them without the functionality that we developed for Active Choices to address dynamic generation of options and cascade updates.
      Please, continue to share your experiences with the Active Choices plugin.

      Best regards
      Ioannis

  3. I started using Jenkins with CHEF and was looking to dynamically populate CHEF resources like role, node,cookbook  and environments etc and but could not fine good example of this.  I found few groovy script examples here and there and I came up with following script after putting them together.

    The following groovy script loads roles in Active Choice input just fine.  Just make the Jenkins node as chef workstation and you can use a groovy script as below to load any CHEF resource to select.  

     def command = "knife role list"
    def proc = command.execute()
    proc.waitFor()
    def roles = []
    roles = "${proc.in.text}" .eachLine { line ->
        roles << line
    }
    
    1. This is a very practical and useful example. Thanks for sharing!
      Best regards
      Ioannis

  4. really nice plugin! add great functionality that ive been missing in jenkins.

    is there a way to specify on which node to run the script?

    or at least make sure it uses the same node as configured in the job like in dynamic parameter plugin?

  5. really nice plugin! add great functionality that ive been missing in jenkins.

    is there a way to specify on which node to run the script?

    or at least make sure it uses the same node as configured in the job like in dynamic parameter plugin?

    1. Hi doron.

      >is there a way to specify on which node to run the script?

      Not at the moment. It always executes the scripts in the master, IIRC.

      >or at least make sure it uses the same node as configured in the job like in dynamic parameter plugin?

      The 0.1 of active-choices plug-in (which was 0.1 uno-choice), was based mainly on the dynamic parameter plugin. We started removing a few parts to simplify and speed up the development, and if I recall correctly the extra classpath and specifying where to run the script where removed.

      Could you fill an issue for that in issues.jenkins-ci.org/, using the component active-choices, please? Will take care of that in the next release, since it'd be really a good feature now that the 1.0 has been released.

      Thanks

      Bruno

      1. sure Bruno, ill add an issue today.

        thanks for the reply

  6. I am not able to access string functions in groovy script example substring,split and others.

    1. Please, file a JIRA issue for the plugin and provide a complete example of what is not working. Is the string in the groovy function passed in as a referenced parameter? Also, please provide as much information as it is available on the Active Choice parameter configuration. Thank you!

  7. I've setup Active Choices Reactive Reference Parameters, but unfortunately when the parameter values get to my jobs they have a trailing comma.  Since the Formatted Hidden HTML type is only visible in the context of the job I'm not sure how to debug this.  I don't see anything for it in JIRA.  My groovy code looks something like this:

    PARM = "VALUE"

    return "<input name=\"value\" value=\"${PARM}\" class=\"setting-input\" type=\"text\">"

    Any ideas?

    1. To remove the 'comma' click the Advanced configuration button and Select 'Omit value field'

  8. Thanks for this excellent plugin. BTW why this plugin is not listed on main Jenkins plugins page here -  https://wiki.jenkins-ci.org/display/JENKINS/Plugins ?
    Recently I played much time with plugin by using scriptler and want to put some notes about using it.

    I short about my jenkins job: 
    It has 2 ActiveChoise params. 1st is used to select xml file-name (each contain list of  test suites), and 2nd - used to select concrete suite from file (defined in 1st param).
    For 2nd param I use scriptler to download and parse xml file.

    Inside scriptler script we have access to:
     * (a) explicit script parameters (defined with scriptler)
     * (b) parameters, defined in 'Referenced parameters' field. (I don't recommend to use them in scriptler scripts. The better idea is to pass them explicitly into script)
    Script params (a) has higher priority (in case we have equal names for both)
    For proper operation (recalculating) we should define all referenced (parent) parameters in field 'Referenced parameters'. This field can contain only ActiveChoise-param types. Other param types will not work.
    In values for explicit scriptler parameters (*a) you also can use only references, listed in 'Referenced parameters' list
    NOTE: all referenced ("parent") parameters should be defined BEFORE current parameter (i.e. they should be placed above current one in Jenkins UI)

    NOTE: in case depended parameters are not updated when you change value of parent, check browser console and jenkins log and fix all error messages.
     Typical error #1 - you return wrong result type (correct type are: list [] and map [:])
     Typical error #2 - you return list (or map) of objects (instead of simple Strings) which have cyclic references

    Example of error #2: code below which is successfully evaluated in scriptler console, fails with JSONException: There is a cycle in the hierarchy when executed from a job. 

    .....
    // extract and return all suite names from external xml file
    def result = []
    xmlRoot.suites.suite.@name.each{result << it}
    return result;

    If you use script as datasource for Active Choice  parameter, you should explicitly call toString() method (in my case it is text() )

    def result = []
    xmlRoot.suites.suite.@name.each{result << it.text()}
    return result;
    1. @oleksandr Thanks for the tips and use case example! The index page is now updated. You'll find the Active Choices plugin at the top of the list for Parameter related plugins.

  9. Has anyone used this plugin to load reference parameters from a properties file? 

    I have this groovy code, can't get it to work :

    Properties properties = new Properties()
    File propertiesFile = new File('/opt/jenkins_home/webroot/integration_apps.properties')
    def stream = propertiesFile.newDataInputStream()
    properties.load(stream)
    
    return properties.getProperty(branches).split(',')
    1. You need to iterate and add each of the values to the Active Choices parameter list

      I use the following groovy script to read comma separated key values from a property file. I keep this static properties in userContent/properties subfolder

      jenkinsURL=jenkins.model.Jenkins.instance.getRootUrl()
      
      def propFile=vPropFile //name of properties file
      def propKey=vPropKey // name of properties key
      def relPropFileUrl=vRelPropFileUrl // userContent/properties/
      def propAddress="${jenkinsURL}${relPropFileUrl}$propFile"
      def props= new Properties()
      props.load(new URL(propAddress).openStream())
      def choices=[]
      
          props.get(propKey.toString()).split(",").each{
            choices.add(it)
              }
      
      return choices

      You'll either need to hardcode or pass to the script the following  script parametersvPropFile , vPropKey ,vRelPropFileUrl
      Hope it helps! Best regardsIoannis

  10. Unknown User (ckutz)

    Is there a way to debug the groovy scripts and where are errors from the groovy scripts are logged?

    I'm trying to parse some git branches into the choice selection, but the script fails and I cannot see why

    1. Yes, you can add a new log recorder for: org.biouno.unochoice and name it what you want: 'biouno' for example.
      Then error messages from unochoice (active choices) scripts will be recorded by this logger and you can review them under Jenkins log

  11. I'm a big fan of this plugin from the days it was "unochoice parameter plugin". 

    I'm now testing it as "active choice plugin" for the first time. It has been changed a little bit in its new generation but I have managed to figure out all the changes.

    Problem is, when my referenced parameter is a Boolean parameter, I can't make it work. The groovy script in the "Active "Choices Reactive Parameter" can't tell when the referenced parameter is true or false.

    I have tried with REFERENCE_PARAMETER.equals("false") and REFERENCE_PARAMETER.equals(false) and they both doesn't work. I have, also, tried other groovy syntax to detect if a Boolean parameter is true or false but they detected the parameter as true. 

    What am I doing wrong or maybe I should open a new issue?

    Thanks

    1. Although a Jenkins Boolean parameter is exposed in the build environment as the String true/false as a build parameter it defaults to 'on' when checked and empty when un-checked. Weird, I admit, but beyond the control of active choice parameters. So to make it work you should be checking 

      if REFERENCE_PARAMETER.equals("on") {\\true_actions} else{\\false_actions}

      Hope it helps
      Ioannis

      1. Indeed it is strange because when I use a Boolean parameter in a shell or groovy script as part of build step, it does evaluate to true/false but your suggestion is good enough for me :-)

        Thanks

        Gil 

      2. Hi Loannis,

        Sorry for answering without testing first but this didn't work for me. It never evaluates to "on".

        I have tried the following to see what it does evaluate to:

        return [REFERENCE_PARAMETER] and this return [REFERENCE_PARAMETER.toString()] and this return [string.valueOf(REFERENCE_PARAMETER)]

        None of the above returned a value while the REFERENCE_PARAMETER was checked and unchecked.

        Thanks

        Gil

        1. Insure that you are returning a list or map in Active choices.

          Assuming that you have a BOOLEAN_REF boolean parameter that your Active Choices Reactive parameter references, try the following script. It works for me

          def options=[]
          if (BOOLEAN_REF.equals('on')){
          options.add('true') }
          else{
          options.add('false')
          }
          
          return options
          

          The result is this:

          1. I know I should return list or map. I was talking about the .equals('on') part. For me it never evaluates to "on".

            I have copied and pasted what you have suggested but for me AC_REACTIVE always shows as false. Doesn't matter if I check or uncheck to BOOLEAN_REF parameter.

            Thanks anyway.

            Gil

            1. Could you file an issue in issues.jenkins-ci.org, component = active-choices-plugin, please? Attach an example config file if possible. I'm suspecting an issue with your version of jQuery. Please, mention this as well as your Jenkins version. Thanks for reporting this!

              1. JENKINS-32044

                Thanks a lot!!

                Gil

  12. Hi!

    We're trying to use the Active Choices Reactive Reference Parameter in order to read the value from a Node Parameter but it's not working (depending on the selected node, we'll show one or another option).

    Is there anyway to achieve this?

    Many thanks in advance and best regards!

    1. Please provide some additional information so I can better understand what is not working.
      As a minimum a screen shot of your configuration for the Active Choice parameter and it's referenced parameter would help. What version of the plugin are you using and on what version of Jenkins.
      Cheers
      Ioannis

  13. Hi Guys,

    Excellent plugin! Thanks a lot!

  14. Hello,

    i use the following script in an Active Choices Reactive Parameter with Checkboxes.

    def list = \[
    "'edict-testgameapi6-pkg:${INPUT_VERSION}\|de.edict.ecg.testgame'",
    "'edict-testgameapi5-pkg:${INPUT_VERSION}\|de.edict.ecg.testgame'",
    "'edict-testgameapi4-pkg:${INPUT_VERSION}\|de.edict.ecg.testgame'",
    "'edict-testgameapi2-pkg:${INPUT_VERSION}\|de.edict.ecg.testgame'"\]
    return list
    
    

    The Result on the jenkins build site are 4 Checkboxes with [object Object] as text.

    What is wrong with the script?

    1. Groovy text in double quotes is treated as a GSTRING object. use the as String or toString() method to turn it into text that can be displayed in an Active Choice list

      so something like the code below should do it :

      //using you list above
      def list=[
      "'edict-testgameapi6-pkg:${INPUT_VERSION}\|de.edict.ecg.testgame'",
      "'edict-testgameapi5-pkg:${INPUT_VERSION}\|de.edict.ecg.testgame'",
      "'edict-testgameapi4-pkg:${INPUT_VERSION}\|de.edict.ecg.testgame'",
      "'edict-testgameapi2-pkg:${INPUT_VERSION}\|de.edict.ecg.testgame'"]
      
      def acList=[]
      list.each{
      acList.add(it as String)
      }
      return acList
      
  15. Hi there,

    Thanks for the great plugin. It does help a lot.

    I've got a couple of questions:

    1. Is there a way to decide which "Referenced Parameter" changed triggered the script re-evaluation of a Reactive Parameter?

    2. Also sometimes loading param list may be a long operation. Browser hangs for several seconds. Is there a way to display something like "loading..." during the back-end script evaluation? I'd be happy to contribute such a feature if have directions where to start from :)

    1. Thanks Vladimir.

      1. I don't think this is supported, but I do think it's a useful feature! It could also help with avoiding re-evaluation of the entire script if only one of several parameters changes
      2. I know what you mean. Glad if you are willing to contribute. Our open source BioUno project depends on this!

      Please, submit JIRA requests against this component: active-choices-plugin

  16. Hello!

    Can I control how many items show for radio buttons or checkbox? How?

    Thanks

    1. There is no direct support in the parameter configuration for this. However, if you review the xml configuration there is a parameter attribute for the number of visible items. Perhaps you can test adjusting it there. I have not tried it myself.

      1. Oh, maybe that could work. Where Can I find that file?
        Thanks.

        Edit: Is in the job's workspace, obviously. Thanks anyway.

        Edit: It seems doesn't work. Nothing change when I modify this param, even when I delete it. Yes, I reload from disk

    1. I believe what you are referring to here is a use case where you display a human readable selection choice but internally you would like to provide a different value. This is supported in Active Choice parameters by returning a Map rather than a List from your groovy script. For example, the map of a test code to a human readbale name could like something like this

      return ['TESTA1':'Include Test A1', 'TESTA2':'Include Test A2', 'TESTA3':'Include Test A3']

      The displayed options will be the map values but user selections will internally be returned as a comma separated list of the map keys. Of course map keys have to be unique (you can't have two N-keys for example) but you can still further parse the key selections in your code to get the info you need.

      Hope this helps
      Best reagrds

  17. Hey there,

    first of all: this is one of the greatest plugins I've found and used so far for Jenkins. It lets me create a fool-proof parameter config so people from other departments cannot select any combination of parameters that will trigger an impossible build.
    This is worth a lot for me and the people I work for.

    But I am looking into ways to improve my jobs, so I kinda got to a problem:

    I have a chain of parameters, one parameter enables a set of new parameters and so on. At the end, I need a String Input that will only be available / enabled, if a certain set of paramters is selected before.
    I have found in Active Choices Reactive Reference Parameters, that there is Input text box. But this is not interactive, it just uses the String I put into the Groovy Script as return.

    Is there a way to use this as an active input field, so you could type in a String as an environment variable?

    Thanks in advance!

    1. Hi, I may not fully understand your use case but I think some of the ideas described here may be helpful. An AC Reactive Reference can provide a build parameter that is both auto-generated from previous parameter choices and can be further edited by the user. I use this approach frequently to auto-generate build names that the user can further customize.

      It seems that the String Input you need should be uniquely generated from the parameters on which it depends on. If you don't want it edited by the user it can be defined as hidden. It will be passed to the build without the user interacting with it.

      I hope this helps.
      Best regards

      1. Hi Ioannis,

        thank you so much, that link you provided was exactly what I needed. I did not find something like that somewhere, probably because I did not search with the old plugin name!
        But yes, that solved it for my issue!

        Thanks again!

        1. Glad you were able to achieve your goal!
          Best regards
          Ioannis

        2. Hi Heiko,

          I have tried the scenario you wrote in you previous comment. I could not able to get the input. Could you let me know how you have fixed it.

          Thanks in advance

        3. Hi Heiko,

          I have tried the scenario you wrote in you previous comment. I could not able to get the input. Could you let me know how you have fixed it.

          Thanks in advance

  18. First of all, this is an wonderful and outstanding plugin.

    Great job folks.  Thank You for this plugin.

    I am trying to take advantage of the Active Choices Reactive Reference Parameter type.  The following image shows the script and the parameter that I am looking at.
    When I try to reference that in the build section I get an empty value as can be seen here.
    Please inform as to what I might be missing.

    -Narahari

    1. Please, see wiki page at Scenario 2 on how to format an AC Reactive Reference so that its value gets passed to the build. You need something like:

      return "<input name=\"value\" value=\"${ReactiveRefParam}\" class=\"setting-input\" type=\"text\">"
      
  19. None Please see my next comment.

  20. Friends:

    Others might have had the same need and fixed it.  Please share your approach to solving it.

    For the active choices plugin series, let us say I want to use JSoup jar or HTMLBuilder jar file into my class path.  How do I make it available to the script that is embedded.

    I tried various things like adding to the groovy plugin etc., but could not get any success.  Where to add the jars so I can take advantage of those jars.

    Regards,

    -Narahari

    1. It's possible that the workaround suggested for a similar issue with scriptler may work, but I have not tried it yet.
      See suggestion here: https://issues.jenkins-ci.org/browse/JENKINS-15878

  21. Hi..

    Firstly thanks for creating such a great plugin..

    Do we have any example groovy for using jenkinsBuild in "Active Choices Reactive Parameter"? I am trying to get value from global environment variable, but not successful so far. Tried using System.getenv(), but which doesn't have the properties defined in "Manage Jenkins ->  Configure System -> Global properties -> Environment variables" section.

    Thanks!!

    1. Jenkins global variables are not exposed until you have started a build. As a result, they are not accessible during UI configuration with the Active Choices scripts. A design that works well is to create global properties in a simple java properties file (key-value pairs) with properties you want to access across jobs and builds. You can save this in JENKINS_HOME/userContent somewhere (I have a dedicated properties folder that I use for different purposes). Then you can access and use these global properties from your Active Choices groovy script. Another advantage of this design is that you can easily transfer such properties across Jenkins instances by coping the properties file. Jenkins global variables are stored in the system configuration file and they are more difficult to transfer to a different system (most likely you'll have to enter them manually)

      1. Thanks for the suggestion, i will use this approach for variables which wont change much frequently. In my case those are usernames and passwords, so i defined them in credentials plug in and able to get them in groovy.

        But i have a different questions now,

        > Do we have any plans on providing the ability to execute groovy script from a file ?

        > Do we have a way to reference external jars for the groovy script?

  22. Hi this is not working for me for Active Choice Parameter as 'choice'

    Example : 

    1. I have 1 active choice parameter "TYPE" with format CHECKBOX with Groovy script as 

    return[
    'BVT:selected',
    'Integration','Sanity'
    ]

    2. Another, i have active choice reactive parameter "PRODUCT"which is bind to "TYPE"

    If my selection contains TYPE as INTEGRATION then some options should be displayed.

    Groovy : 

    if (UIExecutionType.equals("Regression")) {
    return [
    "Event",
    "Express",
    "Admin",
    "Survey",
    "SMM",
    "Contacts",
    "Emarketing",
    "Appointments",
    "CFP"
    ]
    } else {
    return["-Not Selected-"]
    }
    if (TYPE.contains("INTEGRATION"))
    
    { return \["Option1", "Option2", "Option3"\] }
    else
    
    { return\["N/A"\] }
    

    This is working fine If i change format of "TYPE" choice as single select,multi select or radio button but not working anyway with checkbox.

    Jenkins Version : 1.625.3

    Please help here and let me know what i am doing wrong, Thanks.

    1. Since this is 'working fine with choice as single select,multi select or radio button' but not checkbox I suspect a bug. What version of Active Choices are you using? Please, submit a JIRA issue on the Active-choices component and provide your code for testing with. Please, note that the example code you provided is insufficient for me to reproduce your error.Thank you!

  23. I am using org.biouno:uno-choice:1.4 for Active+Choices+Plugin and Jenkins Version is 1.625.3.

    Will raise a ticket as suggested.

  24. I am trying to use "Active Choices Reactive and Reactive Reference Parameters" with NodeLabel Parameter Plugin\ I set Active Choices relying on UI element change (Node drop down list ), however the value of "Referenced parameters" using from node selection $NODE_NAME is empty. looks like $NODE_NAME isn't auto responding the selected value until built. does "ACP" plugin support the Node selection as Referenced parameters?

    I set "Disallow multi node selection when triggering build manually" to get single drop down list.

    I also post the question here https://wiki.jenkins-ci.org/display/JENKINS/NodeLabel+Parameter+Plugin?focusedCommentId=100696593&#comment-100696593

    1. We have seen a few cases where we needed to adapt AC to accept certain special types like 'File parameter'. Perhaps this one of these cases? I'm not familiar with NodeLabel so I've never run into this. Please, submit a JIRA issue on the Active-choices component and provide some example code or screenshots to demonstrate the issue.

  25. Hi,

    First, this is a really nice and usefull plugin! Just i got a small problem.

    In Active Choices Reactive Reference Parameter if i select input text box as choice type:

    1. I got a really small text box as a result

    2. It`s not editable

    What i am trying to do is to read a file and return the content of it based on the reference parameter.

    The script works well but with the two problems mentioned above it is a bit useless.

    Am I doing something wrong or this is a limitation in the plugin?

    Here is an example
    Thanks

    1. Yes indeed the default input box has these limitations. You want to select the 'Formatted HTML' option instead. This way you can render your TEXT control anyway you want. Your Groovy script will haveto return valid HTML with the file.text as the HTML element value. For a simple, but editable, text input box for example you can use something like

      return "<input name=\"value\" value=\"${ReactiveRefParam}\" class=\"setting-input\" type=\"text\">"
      

      Where ReactiveRefParam will be the value of your file.text

      Hope this helps!
      Ioannis

      1. Thanks, the 'Formatted HTML' option helped!

        I used the textarea tag which resulted a nice resizable text input box!

        String fileContents = new File('/path/to/file').getText('UTF-8')
        
        return "<textarea rows=\"10\" cols=\"100\">${fileContents}</textarea>"
        
      2. Just a small correction with a reset button addon. Now this works.

        return "<textarea name=\"value\" rows=\"10\" cols=\"100\">${fileContents}</textarea><p><input type=\"reset\">"
        
  26. @jozsef sin, can you paste your active choice groovy where you are reading values from a file ?

    1. Hi Gupta!

      I tried these three mode but all three resulted the same text box you see in the attached pic.

      import jenkins.*;
      import jenkins.model.*;
      import hudson.*;
      import hudson.model.*;
      //#1
      def getProperties = [ 'sh','-c',"cat /path/to/file" ]
      String properties = getNodeProperties.execute().text
      //#2
      String fileContents = new File(' /path/to/file').getText('UTF-8')
      //#3
      new File(' /path/to/file').eachLine { line ->
        println line
      }
      if (SYSTEM.equals("CHOICE_1")) {
        return properties
        //return fileContents
        //return File
      } else if (SYSTEM.equals("CHOICE_2")) {
      return "Simple text"
      }

      //#1
      def getProperties = [ 'sh','-c',"cat /path/to/file" ]
      String properties = getNodeProperties.execute().text
      
      //#2
      String fileContents = new File(' /path/to/file').getText('UTF-8')
      
      //#3
      new File(' /path/to/file').eachLine { line ->
        println line
      }
      
      if (SYSTEM.equals("CHOICE_1")) {
        return properties
        //return fileContents #2
        //return File #3
      } else if (SYSTEM.equals("CHOICE_2")) {
        return "Simple text"
      }
      
  27. Thanks guys problem solved see my posts above.

  28. 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' ) }
                      .sort()
                      .reverse()
    //Option to remove extension:
    //                  .collect { it[ 0..-5 ] }
    

    .

  29. I absolutely love this plugin, and use it for some really powerful controls!  I have a groovy script (in scriptler) that runs as part of an Active Choices Reactive Reference Parameter returning Formatted HTML, and basically loads and external files with tests cases, and displays a treeview of checkboxes, repeat counts for each test case, producing a single output value that combines the selection options. But I've run into a case where I'd like my groovy script to be able to dynamically iterate through the dependent parameters that are known at "runtime" (i.e. when the plugin is running the script to generate the build parameters HTML in this case). So not to be confused with getting the build parameters when the build has actually been kicked off, which I know how to do.  I don't know if this is a general Jenkins question or AC question, but I wanted to start here.  

    My example would be if a freestyle job has an Active Choices Reactive Reference Parameter's, which calls a groovy script in scriptler, and the parameter is configured to pass a few variables (let's call them "A" and "B", with values 1, 2 respectively) to the script. Although the script can directly reference A and B as variables, is there a way to dynamically get all local variables that were passed to the script, such that it would include A and B (if it includes other variables, I could live with that).  

    Any creative ideas? :)

    Thanks,
    Bill

  30. I absolutely love this plugin, and use it for some really powerful controls!  I have a groovy script (in scriptler) that runs as part of an Active Choices Reactive Reference Parameter returning Formatted HTML, and basically loads and external files with tests cases, and displays a treeview of checkboxes, repeat counts for each test case, producing a single output value that combines the selection options. But I've run into a case where I'd like my groovy script to be able to dynamically iterate through the dependent parameters that are known at "runtime" (i.e. when the plugin is running the script to generate the build parameters HTML in this case). So not to be confused with getting the build parameters when the build has actually been kicked off, which I know how to do.  I don't know if this is a general Jenkins question or AC question, but I wanted to start here.  

    My example would be if a freestyle job has an Active Choices Reactive Reference Parameter's, which calls a groovy script in scriptler, and the parameter is configured to pass a few variables (let's call them "A" and "B", with values 1, 2 respectively) to the script. Although the script can directly reference A and B as variables, is there a way to dynamically get all local variables that were passed to the script, such that it would include A and B (if it includes other variables, I could live with that).  

    Any creative ideas? :)

    Thanks,
    Bill

    1. So, that I can understand this better, are you asking if the AC script has access to other 'local' variables in addition to the referenced ones A, B ?
      Can you please explain what do you mean by local variables (other build parameters?, Jenkins global variables? environment variables, other?)

      I understand that you don't want to use those variables at run/build time but just so that you can parametrize the AC scriptlet.
      Environment variables are typically available from within the scriptlet that is running in the same VM as Jenkins.

      1. Right, so I guess two scenarios, which may have the same solution but please let me know. So let's limit the scope to variables that the AC Reactive Reference Parameter is configured to know about. And in both cases we're using a scriptler script (as opposed to inlined groovy script).

        Case 1: We leave the "Referenced parameters" field empty, we have two parameters explicitly passed (A="1", B="2").  

        Case 2: A ("1") and B ("2") are Active Choices parameters, and the AA RRP has "Referenced parameters" configured with these ("A, B"), but no parameters are explicitly passed to the scriptler script.  

        In either/both of these cases, is there a way within the scriptler script to access these variables dynamically without knowing their names?

        My goal is to build a map of key/value pairs in the scriptler script, dynamically generating it from these variables that are passed. Note that the scripter script gets reused in other AA RRPs so it can't explicitly reference A and B, but needs to "discover" these at runtime.  Is there a way to do this?  Again it's possible this is a general Jenkins question, but I'm hoping you can clarify for me.

        Thanks,
        Bill

        1. Bill, when working with a groovy script I can use the script 'binding' to dynamically review the parameters that are passed.

          import hudson.model.\*
          binding.variables.each{k, v->
          println "$k, $v"
          }

          Perhaps you can use something similar in the scriptlet to review the available binding variables. If you do not reference any build form parameters then they will not be included in the binding. You'll find that the binding only includes  global Jenkins configuration parameters
          Hope this helps
          Ioannis

          1. Ioannis, that works great!  I tried it in a few environments, and came up with a script that filters out the few referenced/passed parameters I'm looking for from the environment variables that also seem to get put in binding.variables.  I noticed the referenced/passed parameters are always at the end, and after 'jenkinsProject' (the order seems predictable), so I iterate through and key off of 'jenkinsProject'.  Note that when run in isolation in scriptler, these extra environment variables don't exist, in which case it's just the referenced/passed parameters.  Also I saw "out" and "listener" were in this list, so I filter those out.  In the end I've got just the parameters I want. :)  Certainly if you know of a simpler way to ONLY get those, let me know, but for now this works great!Thanks,

            Bill

  31. Hi guys,

    I'm not able to add this plug-in to the newest Jenkins (2.54, 2.46.1, 2.32). Plugin manager cannot find this plugin anymore.

    We heavily relied on this plugin.

    Could you help how/where can I get the hpi?

    Regards,

    Robert

  32. Hi,

    When this plugin will be available for Jenkins 2.46.1. We are heavily dependent on this plugin.

    Regards,

    Javed

  33. Like Robert above,  we are unable to find the Active Choices plugin from the plugin manager.  We are using 2.54.  Is there an update on when this will be available?

     

    Thanks,

    Sean

  34. Where is the previous version archive link?

  35. Have been testing the Active Choices plug-in for a couple weeks on a Dev server with good success, its been working great.

    However, I just upgraded our Production Jenkins server to 2.46.1 (from 1.642.4 –  upgrade is required for the plugin-compatibility) but now as others have mentioned the Active Choices plug-in is NOT available, and nowhere to be found.  Is anyone looking into this? Need this functionality for several code workflows.

     

    Thanks

     

     

  36. Have been using the Active Choices plugin on a Dev server for several weeks with good success.


    However, just upgraded our production Jenkins server from 1.642.4 to 2.46.1 in order to start using the Active Choices plugin, but the plugin is NOT available and nowhere to be found. Any ideas?


    Thanks

  37. Any idea if the plugin will be available anytime soon?

    Thanks 

  38. created a blocker JIRA ticket regarding to disappeared plugin download repo:
    https://issues.jenkins-ci.org/browse/JENKINS-43663

     

  39. Hi Mates,
     Security guys from Jenkins should be executed. I would fire IDIOT  who takes the decision about get rid all these useful plugins.

    Probably that guy is as stupid as a nut. If they wanted to improve security they should introduce the flag - Yes I wanted to use insecure plugins.

    But probably security IDIOT   don't even think that thousand of people are using that plugin on productions, and they will use old plugins and unpatched Jenkins server. 

    Ok quick workaround the uno plugin is secure but it's relays on scriptler who is not secure - tho the security idiot YES I WANT TO USE THIS INSECURE PLUGIN.
    So the first  read this 

    Fixes have been released for the following plugins:

    Next go here:
    https://repo.jenkins-ci.org/releases/org/biouno/uno-choice/

    and here 

    https://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/scriptler/2.9/

    Install plugins according to this manual

    https://jenkins.io/doc/book/managing/plugins/#advanced-installation


     AND DO  the plugin backups because any other idiot can take decision about remove plugin from repo.
    GOD save us  from  such SECURITY  idiots

  40. Thank you pete pete

    for providing the download location of those plugins~

     

     

  41. Sorry for not updating this discussion thread at an earlier time. I had posted this at the Biouno user's group though:

    https://groups.google.com/forum/#!topic/biouno-users/p3ZfSTPIOQs

    I'm not happy either with the way these plugins (on which many people are relying on to do actual work) disappeared from the Jenkins update center. However, Jenkins has become such an integral part of many DevOp shops that security concerns are not to be ignored. As it was correctly stated earlier although Active Choices is using the recommended script security plugin it relies on the Scriptler plugin which has not gotten the security update. As a result both of these plugins are banned from the official update center and need to be manually installed from the maven repository.

    See also here on how to configure the Biouno update site as an alternate plugin repository: http://biouno.org/installing-plugins.html

    I hope this can assist you in continuing to use the Active Choices plugin while we are looking for a more permanent solution.

  42. @Ionnis  

    "DevOp shops that security concerns are not to be ignored" So, in this case, we should turn off our mobile phones, our computers everything.
    Probably you will be more secure but you will be also out of the business.  Devops is about providing business value as quick as its possible.
    Jenkins is a very specific product.  It's not exposure tho millions of client like for example Apache2 server. It's used internally. Very often in dedicated networks segment. From my point of view,  JENKINS should publish a list of plugins which they wanted to block at least 6 months in advance. Ok0 if you are using Jenkins at home probably blocking those plugins is not a big pain in your ass, but if you are using on production and whole business relying on that......... 
    In another world from my point of view Security guy who took this decision should be fired immediately!!!!!!(way how it was introduced is totally unacceptable)
    one more time from my point of view Jenkins should introduce flag "I wanted to use insecure plugins" and provide separately repo for that plugins. pLease keep in mind that almost all plugins are based on open source and authors sometimes don't have enough time to fix everything.
     

  43. I have given this a look-see and I'm not seeing what I'm looking for, but maybe I'm blind.  I want a drop-list in which the options have different names exposed to the user than values.

    Something like this in html:

    <select>
    <option value="https://blahblahblah_new_york.com:12345">New York</option>
    <option value="https://blahblahblah_london.co:674">London</option>
    <option value="https://bimbambim.fr/paris:3232">Paris</option>
    </select>


    The use case is where a simple well known abbreviation for a complicated actual value exists and we want to expose the abbreviation to the user.

    Does support for this use case exist?

     

    1. Hi Steven.

      If you return a java.util.Map, keys will be parameter values, and values will be the display value. If you return a java.util.List/Array in your Groovy script, then we will actually create a Map and populate it with key/value = each list entry value.

      Hope that makes sense?

      Cheers

      Bruno

      ps: we should probably add it to the documentation. I won't have time to do a proper job, with screen shot etc. But here's a note to anyone with time (smile)

  44. Hi Bruno/Ioannis, 

    Thank you for this plugin.

    This is my first attempt on Active Choices Reactive Reference Parameter.

    We have a table containing list of parameters.

    We are building a jenkins plan which will pull data from that table and show as a build parameter using groovy. Am trying to use Formatted HTML option for following scenario. There could be multiple parameters based on previous prompt. Parameter could be a list of values based on select statement from database or Free Text or static list. 

    Currently, I was able to achieve the above mentioned details but user selected values are not passed as build parameter. 

    Example Scenario:

    Prompt one(fixed list of choice): List of countries

    Prompt Two(Active Choice Reactive Reference): Generate Html having two additional parameters, one parameter is a select multiple option , list of states and other is text, lets say primary language. 

     

    Is this scenario achievable?

     

     

     

    1. Update:  Got the selection working. <select name=value multiple> <option> </option> </select> worked. I had select named differently earlier.

       

      Is there any way to distinguish multiple input types in one parameter ? 

      For example (above same scenario):

      Country is selected as USA

      Second_prompt:

      • Prompt 1 (multi select): New Mexico, Texas 
      • Prompt 2 (text): English, Spanish

       

      In above scenario, my build parameters are shown as 

      Country: USA

      Second_prompt: New Mexico, Texas,English, Spanish

       

      I am not able to distinguish what are the sub prompt values. 

       

      Appreciate you time 

      1. If the parameter options are generated from a single job parameter using HTML controls, you will need a clever way of parsing the different parts of the value.

        Perhaps, you can think about including some 'delimiter' HTML that can be used for splitting the parameters once your build starts. In general I would recommend using separate Active Choice Reactive  or reactive reference parameters as they make the distinction more clear.

        1. Thank you Ioannis. We went with separate Active Choice Reactive Parameter.

           

          How does Formatted HTML parameter works? Can i enable it based on some value?

          1. I mean Formatted Hidden HTML Parameter. how to set its visibility?

  45. Formatted Hidden HTML is an option type for AC-Reactive Reference parameter. take a look here for an example Reactive Reference Dynamic Parameter Controls

  46. I'm having trouble with the Reactive Parameter type and I'm not sure if it's a bug with the plugin or with my groovy scripts.

    So I have an "environment" active choice parameter with single select. All it does is return a string for dev, qa, etc. I have a "cluster" reactive parameter that references environment param and returns a url string as single select. Both of these seem to work fine.

    The problem arises when I have another reactive param called "repo" that references the "cluster" param. It's a short groovy script that curls the "cluster" url and parses json to return a list of values. What I'm seeing is that every time I change the "environment" param it correctly updates the "cluster" url but the "repo" reactive param is always one behind the change in "environment."

    Example: I select "dev" environment. "cluster" updates properly. "repo" doesn't do anything. Then I select "qa" environment. "cluster" updates properly. "repo" returns the values that "dev" should have. Then if I go back and change environment to dev, then the "repo" param shows me the results from qa.

    I've searched everywhere and tried many many things, but I can't seem to get anywhere on this. Help would be much appreciated!

    Here is my groovy script for the "repo" reactive param.

    import groovy.json.JsonSlurper
    
    url = "${cluster}/_snapshot"
    process = [ 'bash', '-c',  "curl ${url}" ].execute()
    process.waitFor()
    data = new JsonSlurper().parseText(process.text)
    List<String> artifacts = new ArrayList<String>()
    for(item in data.keySet()){
      artifacts.add(item)
    } 
    return artifacts
  47. See if things improve by adding both 'environment' and 'cluster' to the refreenced parameters of 'repo'

    Also what version of the Active Choices Plugin are you using. The latest v2.0 has a regression error that makes the parameter updates somewhat random

    1. I'm seeing the same behavior where "repo" is always one behind. (sad)

    2. Ah, forgot to reply to your other question! It is on v2.0. The updates don't seem random, it's pretty expected that it's always one behind. What do you suggest?

  48. It is definitely a problem with 2.0. Sorry to hear that you wasted time troubleshooting this.

    JENKINS-47908 - Getting issue details... STATUS

    It works perfectly with v1.5.3. Find an example project configuration

    config[1].xml

    1. It appears that v1.5.3 requires Scriptler Plugin which is suspended for unresolved security vulnerabilities. (sad)

  49. This is my requirement to have parameters(Which should be editable after auto displayed) in Jenkins:

    1. User selects 3 Values from Components: DEV, QA, PROD
    2. Upon selection I need to return single or multiple values as parameter as like this:
    If DEV selected, return "Development http://dev.com 1" and "Development http://dev1.com 2"
    If QA selected, return "QA http://qa.com 1" and "QA http://qa.com 2" and "http://qa.com 3"
    If PROD selected, return "Production http://prod.com 1"
    3. Once the value is returned in a variable, I will use that variable values in next step of 'Jenkins build'

    NOTE: Which ever it returned the above values, it should be editable also

    Kindly help me

  50. Hey, awesome plugin, it's working great for me.

    Is it possible to use credentials in the groovy script?

    I am querying an API that requires authentication and I don't want to have the access key in the script itself. I have tried various ways using credentials plugin but cannot get it to work.

    Any help is hugely appreciated. 

    Thanks

    1. Hey Chris, I can see the use case for that, and having a working example in our Wiki page for that would be useful for other users. I haven't had to use the Credentials Plug-in in Active Choices, but did use it in a couple of other plug-ins before. So keen to give it a try and see how easy it would be to use the two plugins together, and whether it requires new code or just some Groovy-fu.

      Could you file an issue in Jenkins for that, please?

      Bruno

      1. Yup, no problem, here it is. Hopefully I've explained it clearly enough. 
        JENKINS-48599 - Getting issue details... STATUS

        Thanks for such a swift reply. 
        Chris

  51. Hi,

     

    First, many thanks for this wonderful plugin!

    I have a problem trying to return the content of a file as checkboxes choices...

     

    1) I set up an Active Choice Parameter 'Zone' which is a simple list of filenames

    2) I setup an Active Choice Reactive Parameter that use the 'Zone' parameter to read a file and return its content.

     

    The problem I have is that the return list all the file content one one line instead of multiple choices...

    Here's the code:

     

    def source = "/jenkins-workspaces/ansible/inventory/"+Zone
    def servers = new File(source) as String[]
    return [ servers ]

    also tried:

    def source = "/jenkins-workspaces/ansible/inventory/"+Zone
    def servers = []
    new File( source ).eachLine { line →
           servers << line
    }
    return [ servers ]

    To me it looks like the function should return a list of options while my code is only returning 1 thing (which is an array).

    This:

    return [ servers[0], servers[1], servers[2], servers[3], servers[4] ]

    is working, but obviously, this is not a solution when you have a variable number of values to return...

     

    Anybody have a clue? Maybe it's a Groovy thing I'm not doing (I'm very new to this language)...

    (Using Active Choices Plugin version 2.0 on Jenkins 2.96-1.1)

     

     

    1. Hi Serge.

      I find that it works as you would expect, using your code and Active Choices v2.0 on jenkins 2.88

      Here is the configuration file:config.xml

      1. ok then, it looks like it's related to the version of Jenkins...

        I updated today to version 0.2.97 and still have the problem.

  52. Hi! Great plugin. One question. Say I have a parameter A, and a "reactive parameter" B that references it. Assume B's Groovy script takes a long time.

    If I select a value for A, it kicks off one call to B's Groovy script.

    Then, if I change A while that script is still running, it kicks off a second call to B's script.

    Depending on which of those two calls finishes first, the value list for B may be different. So it may not correspond to the currently-selected value of A.

    Is there any way to work around this? Thanks.

  53. I think this is related to a known synchronization bug (see:JENKINS-47908) in the initial release of Active Choices v 2.0. You should not be able to change a value in a parameter while a script for another parameter on the page is still running. We are currently testing a fix and should be released soon. The plugin hpi with the fix is attached to the issue and available here 

    1. Thanks for the quick reply! I just installed that update, and it seems to work. Although I don't always see the "Loading" mask over the screen...sometimes the screen just freezes until one of the scripts is complete.

  54. Hi! Is there a way to hide some parameters on selection of other parameter? I want the complete parameter to be hidden and displayed on selection. Can some one help me with example.

    1. Yes, The parameter that should be hidden (based on certain logic) should be a 'Reactive Reference' rendered as HTML. Since HTML elements support the boolean  'hidden' attribute, the script logic can reset this attribute depending on the referenced parameters

  55. Hello.

    I'm trying to execute Groovy script in "Active Choice Parameter" and it doesn't work. Script is ok, because it works fine if I insert it in "Build" part of job config.

    Script is supposed to retrieve list of releases tags from github (*** is just to hide github account and repo for posting here):

     

    import groovy.json.JsonSlurper

    def token = System.getenv("GITHUB_TOKEN");

    def url = "https://api.github.com/repos/***/***/releases".toURL();

    def content = url.getText(requestProperties: ['Authorization': 'token ' + token]);

    def contentList = new JsonSlurper().parseText(content);

    def data = [];

    contentList.each {

        data.add("${it['tag_name']}");
    }

    return data;

     

     

    But in "Build"  I'm able to select version of Groovy that will execute this script and not able to do it in "Active Choice Parameter", can it be the reason of the issue?

    Screenshots:

    Does not return list and hence doesn't render single choice list:

    UPD:

    I did a small research and looks like script keeps failing on this line:

     

    def content = url.getText(requestProperties: ['Authorization': 'token ' + token])

     

    How to find out why it keeps failing here?

  56. I'm not sure, but the Build environment is not the same as the environment available during the form setup. I would test to see what environment variables are available at this stage

    1. yes, unfortunately you're right...  plugin cannot get access to a build env vars... that's why it keeps crashing...

      Is there a way to avoid it and pass env var from a build to the plugin?

      1. >Is there a way to avoid it and pass env var from a build to the plugin?

        When the plug-in is called, it doesn't have a build/run in Jenkins. You could never have built it. Or we could have matrix builds happening, and which one would be the right build to retrieve?

        So the short answer is no.

        However, said that, if you really need to access the build, you can craft some Groovy code for that.

        Looking at your original request, I'm not sure whether you need access to the build in Jenkins, or just to environment variables that get injected for the build. If it's the latter, then perhaps we could investigate how to access those variables. Not sure if that's doable, but if that's your case, feel free to report an issue with the active-choices-plugin component.

        Hope that helps,

        Bruno

  57. Hi Team. I really enjoy working with this plugin, but now I have an issue. Hope you can help

    I'm getting this error in my browser console when using the "Active Choices Reactive Reference Parameter" - 

    Avoiding infinite loop due to recursion!

    My job has 3 parameters:

    1. Param1 Active Choice Parameter - that is returning a list of elements
    2. Param2 Active Choices Reactive Reference Parameter - that is displaying Param1
    3. Param3 Active Choices Reactive Reference Parameter - that is displaying Param2

     

    Anybody had the same issue?

  58. I think that this is a debug left-over message not an error. Are the parameters working as expected?

  59. Can a shared pipeline library be used within Active Choices parameters?

  60. The value for Active Choice Reactive Reference Parameter is not getting populated as environment variable. I am new to this not able to understand much. Please help me in understanding this.

    1. This is the limitation currently with the parameter as suggested -

      Known Limitations

      1. - The parameters are supposed to be handled only by humans, and at the moment do not work when the job is triggered by plug-ins, API or scripts. Please see this issue for more.
    2. Jenkins will pass build form parameters as environment variables to the build. So to get an AC Reactive Reference into the build environment you need to go format this parameter appropriately and also go  into the <Advanced> options and check the <Omit value>  checkbox. If you are rendering the AC Reactive Reference as 'visible HTML' the key is to have an HTML element whose name="value". This is the signal for Jenkins that this is a UI parameter and should be passed to the build. Review the plugin wiki section Passing Reactive Reference Values to the build (scenario 1 and Scenario 2)

       

      1. Thanks a lot Ioannis.. it worked..

        1. One more question. If I add name="value" to the select element type, will  it work?

  61. Any possibility to get option to show all values from list? (currently if list if long scroll bar comes visible)

    1. I have not observed this issue with lists over 1500 options long. Could you please, provide some details on the browser, Jenkins& plugin version used and ideally an example configuration that we could use to reproduce the issue. Feel free to file an issue for Active Choices on the Jenkins Jira

      1. Just to ensure that we are talking about same issue (smile)

        I would like to get rid of this scroll bar, just to show all values without scroll bar no matter how long list is.

        1. Thanks for explaining further. If you want to make selections from the list then the drop down list is your only option. However, if you just want to display the list, then you can use an Active Choice Reactive Reference and selected 'bulleted list' as the 'Choice Type'.

          This should display the entire list as 'bulleted' options, but you will not be able to select from it.

          1. Ok, thanks. Maybe i will create improvement request based on this.

            1. FYI, made workaround for this with Simple Theme plugin and Extra CSS setting.

              div[id^="ecp_choice-parameter-"] { overflow-y: visible !important; height: auto !important; }

  62. Greetings! I'd like to ask for help with a problem I'm facing related to the Active Choices Parameter plugin, it seems that I'm not being able to populate the Reactive parameter when I change values from the regular Active Choice Parameter and can't figure out why, I've copied and pasted several standard examples from different sites (even the basic examples shown in this very page) to no avail.

    I'm attaching a few screenshots from the job configuration with both parameter configurations, another screen showing how it looks when running the job, and finally a capture from the console output (I find it weird that the "Values retrieved from Referenced Parameters: prodType=" has no values at all, but I'm not sure it has something to do with my problem)

    Screens:

     

    Any help is greatly appreciated!

  63. In your example, prodProps would need to be defined after prodType, since the parameters are processed top to bottom (so in your case prodType hasn't been evaluated when prodProps is trying to get its value). So just swap the order of prodProps and prodType and you should be in business.

    Bill

    1. Bill, thank you for your response! Unfortunately my screenshots got mixed up when uploading, looking like prodProps is on top and prodType goes after, but I already had both properties in the order you suggested (I didn't know the details about how the parameters were processed from top to bottom so your message was helpful), so it seems there must be something else that is not right...

      Thanks again for taking the time to answer!

      EDIT: I totally misunderstood what you suggested and thought you were referring to the job configuration page, but as soon as I changed the property names to "A_prodType" and "B_propProps" so that they actually show in the corresponding order in the page, everything started to work as expected, thank you so much Bill, you were absolutely correct!

  64. Greetings! I'd like to ask for help with another problem I'm facing: I can't figure out a way for storing/persisting a value taken from one of the parameters and then append it into a visible text field, in other words, each time I press a button (i.e.: "NO AGREGAR" in the example below), I would like to get the value from D_SelectedConfig and append it to a text field (or another parameter choice, not sure which could be useful in this case) in the very same job execution page, without losing the already inserted/appended text.

    Do you guys happen to know any workaround or solution for this? Thanks in advance!

    -Marcello

    1. In case my question is too vague, what I need is something (groovy script?) that lets me append other Active Choice Reactive parameter values into, for example, a Formatted HTML Reactive Reference parameter (without clearing this parameter each time another parameter is refreshed)

    2. Hi Marcello;

      Yes there are a couple different ways to do this. The simplest is to self-reference an AC parameter. This way you can update the old value (for example you can append to it like you suggested)

      You'll need some logic to keep the AC Reactive Reference from firing more than once depending on the referenced parameters. I have quickly put together a demo for this (project configuration attached).

      config.xml

       

      There is a more elegant way using javascript. In this case, you update the AC html element value using  javascript. Both the Javascript and the updatable HTML element are placed on th eform with an AC Reactive Reference parameter. I will have to work on writing an example for this, but hopefully this will get you started

      1. Hi Ioannis, hi Bill, thanks for chiming in! I've been battling with this and looks like that even after following Ioannis' example I've still not been able to accomplish what I was looking for, so this time I'll try to explain it more precisely, step by step, and with a real case scenario (additionally, I'm also attaching the corresponding config.xml)

        In this case, I never get F_FINAL to populate with the string built in D_SelectedConfig (so I'm also not able to append anything to it)

        This is the config.xml file:

        config.xml

        What changes do you suggest I do?

        Thanks again for all your help! you guys rock (smile)

    3. Narrowing things down a bit... the problem seems to be that every time I select a different value in parameters "A_ProductType" or "B_prodProps", the refresh cascade clears the resulting (and formatted) string in D_SelectedConfig, so I'm not able to "store" or "persist" the values selected previously, it's driving me crazy and can't figure if it's something I'm doing wrong or actually a limitation of the plugin/jenkins.

  65. Hi Marcello, I might be able to help, but could really use more specifics. Can you give a complete series of steps in an example, with some sample values?  If you are able to attach a config.xml that corresponds with the example, that would be extra helpful.

    Bill

    1. Hi Bill, I've added a more detailed explanation of my problem along with the corresponding config.xml in my post above, thanks for your help!

      1. Hi Marcello,

        I dug in on this for awhile, using the sample config.xml and playing with it until I could get some traction. I had some struggles initially with getting my head around your sample, since it has so much going on. But I think I got to the bottom of the issue, or at least should get you a lot closer. 

        What I saw was that it seems that when Active Choices Reactive Reference Parameters trigger downstream changes (such as D_SelectedConfig triggering an update to F_FINAL), their value doesn't come through in the groovy script of the downstream parameter.  Re-creating D_SelectedConfig to be an Active Choices Reactive Parameter allowed F_FINAL to properly use D_SelectedConfig's value.  This also required picking a different choice type, so I went with Single Select and changed the groovy script to return an array (using square brackets) of a single value (i.e. the json as a string).  For example:

            return ["{\"product_type\": \""+A_ProductType+"\"},"]

        That got F_FINAL to show the value based on D_SelectedConfig, but it wouldn't concatenate prior values of F_FINAL (i.e. the self-referential part), but would instead just keep matching D_SelectedConfig as it changed. To fix this, I also had to change F_FINAL to an Active Choices Reactive Parameter.  As with D_SelectedConfig, I had to choose a different choice type, so again I chose Single Select and changed the groovy script to return an array of the single value:

            if (!F_FINAL.endsWith(D_SelectedConfig))

                newMessage = [F_FINAL+" "+D_SelectedConfig]

            else

                newMessage = [F_FINAL] 

        Also this may help. I noticed after changing F_FINAL to an Active Choices Reactive Parameters, the first time loading the page (i.e. clicking "Build with Parameters"), F_FINAL would have the value from the fallback script ("error in parameter F_FINAL").  By adding some logging, I tracked it down to the two referenced parameters (D_SelectedConfig and F_FINAL) not being loaded yet.  The groovy script for F_FINAL actually gets called twice, with it failing the first time, and succeeding the second time (when those parameters are actually valid).  To get around this, you can add a try/catch around the script. That way it's a no-op the first time, and subsequently will work as expected.  Note that println will log to jenkins.out.log.

            try {

                if (!F_FINAL2.endsWith(D_SelectedConfig))
                    newMessage = [F_FINAL+" "+D_SelectedConfig]
                else
                    newMessage = [F_FINAL]

            } catch (all) {
                println "Caught exception: " + all
            }

        As far as the logic of FINAL.endsWith... I don't know if it's working as designed, but I'll leave that to you. Hopefully this all helps.

        Oh, one more note. It didn't seem to cause any problems, but may keep your parameters from working as expected. But I saw D_SelectedConfig includes E_AddProduct as a dependency. But since E_AddProduct is defined after D_SelectedConfig, and reactive updates happen in the order top to bottom order of the parameters, I don't believe changes to E_AddProduct will ever trigger an update to D_SelectedConfig. 


        Bill

  66. Can someone tell me if this is available for multi branch and if so, to make it work.  Please

  67. Question - has this been fixed in any latest plugin release?

     

    1. JENKINS-36590: Active-Choice jenkinsProject variable is not available under Folder or Multibranch-Multiconfiguration job
  68. hi - very useful plugin indeed. trying to do some work with it and had partial luck so far, wonder if someone can help.

    the reference option here is VERSION, which is first chosen by the user. based on that, I am trying to query Jenkins for latest stable build of this version and populate a text box so the user can see it.

    the query script is this - very simple one:

    import jenkins.model.Jenkins

    if (VERSION.equals('2018.1.0')){
    def test_job = Jenkins.instance.getItemByFullName("<some job name>")

    last_sucessful_build_number=test_job.getLastStableBuild().getNumber()
    return [last_sucessful_build_number]

    }

    I would expect the value will be displayed based on the version being chosen but that doesn't happen. 

    I am not able to see the value of this query in the text/list box when running the job, it's empty at all times. 

    what am I missing here ? 

     

    Gabby

     

     

    1. Gabby, try returning the object as string

      return [last_sucessful_build_number as String]

      Also, it would be useful to know what type of ActiveChoice parameter you are using for this. What would work in this case is a AC reactive parameter referencing the VERSION parameter.

  69. yes, I do use the AC reactive parameter . will try your advice, thanks a lot. 

    Edit - it worked (smile) .

    I have a another small question (maybe it's a groovy one actually, not really a groovy guy (smile) ) - how do I get the version selected directly without checking every case (VERSION.equals) ? that way I can use it
    right away since we have a convention for job names. 

     

  70. How to use this plugin in pipeline? I tried to use below code snippet in options, properties, script inside a stage but none is worked

     

    input message: '', parameters: [[$class: 'CascadeChoiceParameter', choiceType: 'PT_SINGLE_SELECT', description: '', filterLength: 1, filterable: false, name: 'States', randomName: 'choice-parameter-3556742860525163', referencedParameters: '', script: [$class: 'GroovyScript', fallbackScript: [classpath: [], sandbox: false, script: ''], script: [classpath: [], sandbox: false, script: 'return[\'NewYork\',\'NewJersey\']']]], [$class: 'CascadeChoiceParameter', choiceType: 'PT_SINGLE_SELECT', description: '', filterLength: 1, filterable: false, name: 'Cities', randomName: 'choice-parameter-3556742865647644', referencedParameters: 'States', script: [$class: 'GroovyScript', fallbackScript: [classpath: [], sandbox: false, script: ''], script: [classpath: [], sandbox: false, script: '''if (States.equals("NewYork")) {
    return[\'Albany\',\'Amsterdam\',\'Auburn\',\'Yonkers\']
    } else if (States.equals("NewJersey")) {
    return[\'Pennington\',\'Chatham\',\'Hillsdale\',\'Ho-Ho-Kus\']
    } else {
    return ["Unknown state"]
    }''']]]]

  71. Hello, I'm willing to translate the plugin in French but didn't find the properties files. Thanks in advance.

  72. Hello,

    Observing following issue when using plugin with groovy script,

     

    FATAL: java.lang.RuntimeException: Failed to serialize hudson.model.Actionable#actions for class hudson.model.FreeStyleBuild
    java.lang.UnsupportedOperationException: Refusing to marshal java.io.PrintStream for security reasons; see https://jenkins.io/redirect/class-filter/
    	at hudson.util.XStream2$BlacklistedTypesConverter.marshal(XStream2.java:543)
    	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
    	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
    	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
    	at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
    	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
    Caused: java.lang.RuntimeException: Failed to serialize org.jenkinsci.plugins.EnvironmentVarSetter#log for class org.jenkinsci.plugins.EnvironmentVarSetter
    	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:256)
    	at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
    	at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
    	at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
    	at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
    	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
    	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
    	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
    	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
    	at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64)
    	at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74)
    	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
    	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
    	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
    	at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
    	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
    Caused: java.lang.RuntimeException: Failed to serialize hudson.model.Actionable#actions for class hudson.model.FreeStyleBuild
    	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:256)
    	at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
    	at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
    	at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
    	at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
    	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
    	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
    	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
    	at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82)
    	at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
    	at com.thoughtworks.xstream.XStream.marshal(XStream.java:1026)
    	at com.thoughtworks.xstream.XStream.marshal(XStream.java:1015)
    	at com.thoughtworks.xstream.XStream.toXML(XStream.java:988)
    	at hudson.XmlFile.write(XmlFile.java:193)
    Caused: java.io.IOException
    	at hudson.XmlFile.write(XmlFile.java:200)
    	at hudson.model.Run.save(Run.java:1923)
    	at hudson.model.Run.setDisplayName(Run.java:803)
    	at org.jenkinsci.plugins.buildnamesetter.BuildNameSetter.setDisplayName(BuildNameSetter.java:76)
    	at org.jenkinsci.plugins.buildnamesetter.BuildNameSetter.access$000(BuildNameSetter.java:31)
    	at org.jenkinsci.plugins.buildnamesetter.BuildNameSetter$1.tearDown(BuildNameSetter.java:64)
    	at hudson.model.Build$BuildExecution.doRun(Build.java:174)
    	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
    	at hudson.model.Run.execute(Run.java:1727)
    	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    	at hudson.model.ResourceController.execute(ResourceController.java:97)
    	at hudson.model.Executor.run(Executor.java:429)
    1. I have fixed it by updating build-name-setter plugin.

  73. Hi, using a "Active Choices Parameter" parameter with the Rebuild Plugin, the UI is not the same when clicking "Rebuild". It's shows like it's a string instead of a drop-down list. Any solution? Thanks.