Child pages
  • Extended Choice Parameter plugin
Skip to end of metadata
Go to start of metadata

Plugin Information

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

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

Adds extended functionality to Choice parameter.


For info on how to use groovy script feature use this Link

Change Log

Version 0.64 (Apr 17, 2016)

Show user friendly error message for script approval issues.

Script security has been incorporated into this plugin for security reasons. You may see warning messages related to security with groovy-script execution from this version on-wards.

A warning message is displayed on the screen if the user tries to execute groovy scripts that have not been approved. The message has a link that takes the user to the screen where the scripts can be approved. The user should have admin access to approve scripts. 

Version 0.61 (Mar 30, 2016)

Use Script Security plugin for authorizing groovy scripts

allow ${JOB_NAME}

variable in properties and groovy file path

expose project and jenkins bindings in groovy script.

Version 0.53 (Jun 02, 2015)

Use faster Boon JSON parser instead of built in net.sef.JSON parser

Version 0.44 (Jun 02, 2015)

Added JSON Parameter feature based on json html editor by Jeremy Dorn
The groovy script should return a JSON object that corresponds to the "options"  object referred to in  json-editor

Watched Fields Ex:

import org.boon.Boon;

def jsonEditorOptions = Boon.fromJson(/{
		disable_edit_json: true,
        disable_properties: true,
        no_additional_properties: true,
        disable_collapse: true,
        disable_array_add: true,
        disable_array_delete: true,
        disable_array_reorder: true,
        theme: "bootstrap2",
        iconlib:"fontawesome4",
		schema: {
		  "type": "object",
		  "title": "Name",
		  "properties": {
			"first_name": {
			  "type": "string",
			  "propertyOrder" : 1
			},
			"last_name": {
			  "type": "string",
			  "propertyOrder" : 2
			},
			"full_name": {
			  "type": "string",
			  "propertyOrder" : 3,
			  "template": "{{fname}} {{lname}}",
			  "watch": {
				"fname": "first_name",
				"lname": "last_name"
			  }
			}
		  }
		},
		startval: {
			"first_name" : "John",
			"last_name" : "Doe",
			"full_name" : "John Doe"
		}
}/);
 


Color Picker Ex:

import org.boon.Boon;

def jsonEditorOptions = Boon.fromJson(/{
		disable_edit_json: true,
        disable_properties: true,
        no_additional_properties: true,
        disable_collapse: true,
        disable_array_add: true,
        disable_array_delete: true,
        disable_array_reorder: true,
        theme: "bootstrap2",
        iconlib:"fontawesome4",
		schema: {
		  "title": "Color Picker",
		  "type": "object",
		  "properties": {
			"color": {
			  "type": "string",
			  "format": "color"
			}
		  }
		},
		startval: {
			color :"red"
		}
}/);


Advanced Ex:

import org.boon.Boon;

def jsonEditorOptions = Boon.fromJson(/{
        disable_edit_json: true,
        disable_properties: true,
        no_additional_properties: true,
        disable_collapse: true,
        disable_array_add: true,
        disable_array_delete: true,
        disable_array_reorder: true,
        theme: "bootstrap2",
        iconlib:"fontawesome4",
       "schema":{
  "title": "Applications",
  "type": "array",
  "format":"tabs",
  "items": {
	 "title": "Application",
	 "headerTemplate": "{{self.name}}",
	 "type": "object",
	 "properties": {
		"name" : {
			 "title": "application",
			 "type": "string",
			 "readOnly": "true"

		 },
		 "environments": {
			 "title": "Environments",
			 "type": "array",
			 "format":"tabs",
			 "items": {
				 "title": "Environment",
				 "headerTemplate": "{{self.name}}",
				 "type": "object",
				 "properties": {
					"name" : {
						 "title": "environment",
						 "type": "string",
						 "readOnly": "true"

					 },
					 "properties": {
						 "type": "array",
						 "format": "table",
						 "items": {
							 "type": "object",
							  "properties": {
								  "name" : {
									  "type": "string",
									  "readOnly": "true"
								  },
								  "value" : {
									  "type": "string"
								  }
							  }
						 }
					 },
					 "servers": {
						 "title": "Servers",
						 "type": "array",
						 "format":"tabs",
						 "items": {
							 "title": "Server",
							 "headerTemplate": "{{self.name}}",
							 "type": "object",

							 "properties": {
								"name" : {
									 "title": "server",
									 "type": "string",
									 "readOnly": "true"

								 },
								 "properties": {
									 "type": "array",
									 "format": "table",
									 "items": {
										 "type": "object",
										  "properties": {
											  "name" : {
												  "type": "string",
												  "readOnly": "true"
											  },
											  "value" : {
												  "type": "string"
											  },
											  "override": {
												"type": "boolean"
											  }
										  }
									 }
								 }
							 }
						 }
					 }
				 }
			 }
		 }
	 }
  }
},
       startval: [
  {
    "name": "agent",
    "environments": [
      {
        "name": "dev1",
		"properties": [
		  {
			"name": "database_url",
			"value": "dev1_url"
		  },
		  {
			"name": "database_password",
			"value": "dev1_password"
		  }
		],
        "servers": [
			{
				"name": "agt11",
				"properties": [
				  {
					"name": "database_url",
					"value": "agt11_url",
					"override": "true"
				  },
				  {
					"name": "database_password",
					"value": "agt11_password",
					"override": "true"
				  }
				]
			},
			{
				"name": "agt12",
				"properties": [
				  {
					"name": "database_url",
					"value": "agt12_url",
					"override": "true"
				  },
				  {
					"name": "database_password",
					"value": "agt12_password",
					"override": "true"
				  }
				]
			}
		]
      },
	  {
        "name": "devprod",
		"properties": [
		  {
			"name": "database_url",
			"value": "devprod_url"
		  },
		  {
			"name": "database_password",
			"value": "devprod_password"
		  }
		],
        "servers": [
			{
				"name": "agt11",
				"properties": [
				  {
					"name": "database_url",
					"value": "agt11_prod_url",
					"override": "true"
				  },
				  {
					"name": "database_password",
					"value": "agt11_prod_password",
					"override": "true"
				  }
				]
			},
			{
				"name": "agt12",
				"properties": [
				  {
					"name": "database_url",
					"value": "agt12_prod_url",
					"override": "true"
				  },
				  {
					"name": "database_password",
					"value": "agt12_prod_password",
					"override": "true"
				  }
				]
			}
		]
      }
    ]
  },
  {
    "name": "consumer",
    "environments": [
      {
        "name": "dev1",
		"properties": [
		  {
			"name": "database_url",
			"value": "dev1_url"
		  },
		  {
			"name": "database_password",
			"value": "dev1_password"
		  }
		],
        "servers": [
			{
				"name": "app11",
				"properties": [
				  {
					"name": "database_url",
					"value": "app11_url",
					"override": "true"
				  },
				  {
					"name": "database_password",
					"value": "app11_password",
					"override": "true"
				  }
				]
			},
			{
				"name": "app12",
				"properties": [
				  {
					"name": "database_url",
					"value": "app12_url",
					"override": "true"
				  },
				  {
					"name": "database_password",
					"value": "app12_password",
					"override": "true"
				  }
				]
			}
		]
      },
	  {
        "name": "devprod",
		"properties": [
		  {
			"name": "database_url",
			"value": "devprod_url"
		  },
		  {
			"name": "database_password",
			"value": "devprod_password"
		  }
		],
        "servers": [
			{
				"name": "app11",
				"properties": [
				  {
					"name": "database_url",
					"value": "agt11_prod_url",
					"override": "true"
				  },
				  {
					"name": "database_password",
					"value": "app11_prod_password",
					"override": "true"
				  }
				]
			},
			{
				"name": "agt12",
				"properties": [
				  {
					"name": "database_url",
					"value": "app12_prod_url",
					"override": "true"
				  },
				  {
					"name": "database_password",
					"value": "app12_prod_password",
					"override": "true"
				  }
				]
			}
		]
      }
    ]
  }
]
}

}/);

return jsonEditorOptions;

Version 0.33 (Jun 09, 2014)

Separated out multilevel single select and multilevel multi-select parameters into separate sections. 

Version 0.32 (Jan 07, 2012)

Added ability to use groovy script to fetch options for parameter.

Version 0.20 (Jan 07, 2012)
  • New field to configure number of items visible in selectbox without scrolling
  • New 'checkbox' and 'radio button' parameter types added
  • changed all validation error checks to warnings
  • added ability to specify an url instead of absolute directory path for property files 
  • ability to specify property references for values, for example
    • prop1=a,b,c,d,e
    • prop2=${prop1},f,g,h  --(prop2 will now evaluate to a,b,c,d,e,f,g,h)
Version 0.5 (Jan 10, 2012)
  • Use a dropdown when using single select mode
  • Trim properties
  • When using a properties file, do not load the file content when editing the job
  • Load the 'latest' property at each build
  • Added some validation for properties file names
Version 0.1 (Jul 14, 2010)
  • Initial release

This plugin allows single select and multi select build parameters to be configured.

Here is a screenshot of the configuration page.

The 'value' field is a comma separated list of values for the single select or multi-select box.
This field can be left blank if the comma separated values need to be picked up from a properties file.
In that case the fields 'Property File' and 'Property Key' need to be filled in.

The 'default value' field is used to set the initial selection of the single-select or mult-select box.
in case of the multi-select box default value can be a comma separated string.
This field can be left blank if the default value needs to be picked up from a properties file.
In that case the fields 'Default Property File' and 'Default Property Key' need to be filled in.

Note: Neither "Property File" or "Default Property File" support referencing environment variables in their values. Thus, their values should be absolute paths specified without using environment variables.

138 Comments

  1. Unknown User (gregmoore)

    how about some text about why I would want to use this. No. I won't take the time to download, install, and try it just to find out it may not be what I need.

    1. Agreed, could do with some notes on what it can do and how to use it. I downloaded it anyway to have a look, but I'm still confused.. Here's a screenshot:

  2. Unknown User (stephane bernigaud)

    This plugin allows to do the long awaited dynamic choice parameter. Great idea.

    But why are results encapsulated with double quotes? This makes the file property of the plugin unusable.

    Ex: I am listing the tags of a svn project in file: TAGS=R1,R2,R3  . Parameter name is $mytag

    When I build the job, I can select $mytag but it contains "R1" and not R1. So the command to extract svn-path/project/$mytag will fail because svn-path/project/"R1" does not exist.

    Is there any way to avoid this? 

    (If I need double quotes, all I need is to include them in the values in the file)

    1. In the 0.4 release I have added a 'quote value' option which can be checked to quote a value. By default the value is not quoted.
      The reason the previous version of this plugin quoted values is because version 1.361 of hudson did not quote values when sending it over to ant.
      I think this issue in hudson was fixed in a later version which is why the value is quoted twice, once by the plugin and once by hudson.

  3. Unknown User (mattiasmelin)

    Nice plugin.

    Is there any way to change the size of the listbox?
    I have many items in my listbox and it is a multiselect listbox.

  4. Unknown User (ms2scale)

    The property file should be evaluated during the build step too, not only if configuring.

    1. The property file does get evaluated when a project is built.
      Can you elaborate more on when you don't see the property file being evaluated?

    2. I'm seeing the same thing, with regards to setting the default for the list.  The list itself does appear to be updating with new values.

      If I change the default in the properties file, it only changes the default parameter if I go to the configure page, and save it. 

      Simply going to "Build Now" does not update the default choice in the list.  (I've only tried this with the single select, not the multi select settings)

      Also, I have tried this using the same properties file for both the default and the list, as well as having them in separate files.

      1. I see the problem, I will have a fix for it soon,

        I am also thinking of replacing all the plugin fields with just one text area field where a groovy script can be entered to configure the parameters. 

  5. Looks like a useful idea, indeed, but where do I place the property file?

    and what is the format?

    Thank you.

    1. The properties file can be placed anywhere on the file-system that Jenkins can access.

      The properties file is a collection of key,value pairs of the form key=value. Here is a link to more information on the properties file format
      http://download.oracle.com/javase/6/docs/api/java/util/Properties.html

      The 'property file' field on  the job configuration page should have the full path to the location of the property file.

  6. Is there a way to use extended choice parameter from CLI or by http "buildWithParameters?parameter1=value" ??
    Right now if I try to pass a value to extended choice parameter i get an error, that ECP does not support CLI commands.
    Or maybe this support is planed in the future?

  7. Is there any way to change the size of the listbox? I have 30 items in my list-box and it's very difficult to multi-select. Also, it would be nice to have a shortcut key to select all the values in the list-box.

    Thanks

    Saran

  8. Hi Vimil

    It's a nice pluggin. Could it be possible to handle env vars in the path fields and not to save the default value when it's picked form a file. If you change it the value is not refreshed.

    Thanks

  9. I would love to see an update to this plugin that incorporates some of the changes people have requested. Especially the ability to limit the size of the select box, or maybe change it to a dropdown if it's a single select.

  10. Can add a size field in plugin config page ? where we can specify the size of the selection box. Currently, it's hard code size as 5.

  11. I am not success to load file data to the "Extended Choice Parameter"

    my file output is:

    bash-3.00$ cat /users/oracle/.jenkins/KF.txt
    TAGS=R1,R2,R3

    And the Property file set to /users/oracle/.jenkins/KF.txt

  12. Hi vimil,

    great plugin, it help me a lot.

    at first, I confused with the option "property key", but now, I have understood it.

    thanks very much...

  13. Status Code: 500
    Exception:
    Stacktrace:
    
    org.apache.commons.jelly.JellyTagException: file:/var/lib/jenkins/plugins/rebuild/WEB-INF/classes/com/sonyericsson/rebuild/RebuildAction/index.jelly:54:63: <st:include> No page found 'ExtendedChoiceParameterValue.jelly' for class com.sonyericsson.rebuild.RebuildAction
    	at org.kohsuke.stapler.jelly.IncludeTag.doTag(IncludeTag.java:124)
    	at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:270)
    	at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
    	at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161)
    	at org.apache.commons.jelly.tags.core.ForEachTag.doTag(ForEachTag.java:150)
    	at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:270)
    	at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
    	at org.kohsuke.stapler.jelly.CallTagLibScript$1.run(CallTagLibScript.java:98)
    	at org.apache.commons.jelly.tags.define.InvokeBodyTag.doTag(InvokeBodyTag.java:91)
    	at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:270)
    	at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
    	at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
    	at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
    	at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105)
    	at org.kohsuke.stapler.jelly.CallTagLibScript.run(CallTagLibScript.java:119)
    	at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
    	at org.kohsuke.stapler.jelly.CallTagLibScript$1.run(CallTagLibScript.java:98)
    	at org.apache.commons.jelly.tags.define.InvokeBodyTag.doTag(InvokeBodyTag.java:91)
    	at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:270)
    	at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
    	at org.apache.commons.jelly.tags.core.CoreTagLibrary$1.run(CoreTagLibrary.java:98)
    	at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
    	at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105)
    	at org.kohsuke.stapler.jelly.CallTagLibScript.run(CallTagLibScript.java:119)
    	at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
    	at org.kohsuke.stapler.jelly.CallTagLibScript$1.run(CallTagLibScript.java:98)
    	at org.apache.commons.jelly.tags.define.InvokeBodyTag.doTag(InvokeBodyTag.java:91)
    	at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:270)
    	at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
    	at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
    	at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
    	at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
    	at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
    	at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
    	at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
    	at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
    	at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
    	at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
    	at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105)
    	at org.kohsuke.stapler.jelly.CallTagLibScript.run(CallTagLibScript.java:119)
    	at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105)
    	at org.kohsuke.stapler.jelly.JellyViewScript.run(JellyViewScript.java:81)
    	at org.kohsuke.stapler.jelly.DefaultScriptInvoker.invokeScript(DefaultScriptInvoker.java:63)
    	at org.kohsuke.stapler.jelly.DefaultScriptInvoker.invokeScript(DefaultScriptInvoker.java:53)
    	at org.kohsuke.stapler.jelly.JellyClassTearOff.serveIndexJelly(JellyClassTearOff.java:107)
    	at org.kohsuke.stapler.jelly.JellyFacet.handleIndexRequest(JellyFacet.java:125)
    	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:552)
    	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:648)
    	at org.kohsuke.stapler.MetaClass$12.dispatch(MetaClass.java:384)
    	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:563)
    	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:648)
    	at org.kohsuke.stapler.MetaClass$12.dispatch(MetaClass.java:384)
    	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:563)
    	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:648)
    	at org.kohsuke.stapler.MetaClass$6.doDispatch(MetaClass.java:241)
    	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
    	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:563)
    	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:648)
    	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:477)
    	at org.kohsuke.stapler.Stapler.service(Stapler.java:159)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:45)
    	at winstone.ServletConfiguration.execute(ServletConfiguration.java:248)
    	at winstone.RequestDispatcher.forward(RequestDispatcher.java:333)
    	at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:376)
    	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:95)
    	at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:87)
    	at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
    	at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
    	at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:47)
    	at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
    	at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
    	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
    	at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
    	at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:164)
    	at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
    	at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
    	at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:81)
    	at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
    	at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
    	at winstone.RequestDispatcher.forward(RequestDispatcher.java:331)
    	at winstone.RequestHandlerThread.processRequest(RequestHandlerThread.java:244)
    	at winstone.RequestHandlerThread.run(RequestHandlerThread.java:150)
    	at java.lang.Thread.run(Thread.java:636)
    

    Extended Choice parameter plugin doesn't seem to work with rebuild plugin

  14. I'm wondering what the main reason to use this plug-in is? It seems to me that the main difference between this and the built-in Choice parameter in Jenkins is that this allows Multi-Select and sourcing parameters from a file. Is that correct? If so, is there any other reason to choose this plug-in over default functionality? Thanks!

  15. Hello,

    Is this plugin only be used in master node? I can't use it in my slave nodes......

    however, it shows the error message "/xxx/yyy/zzz doesnt seem to exist.", but I'm sure the file do exist, and the connection to the slave node is also ok...

    1. after verify it again and again, I found it can only be used in master node.

      and actually, it can be also use din slave nodes, but you need put the list files on the master, and use the absolute path which located in master machine...

  16. Would it be possible to have other input types than a drop down list four the 'Choice' option? The 'Extended Choice' can be presented as checkboxes, radio buttons, etc ... I do need that feature but want to avoid the overhead of a config file on the master. Hopefully it should be simple to implement.

    1. version 0.23 of the plugin can show parameters as radio-buttons, check-boxes or a text box, The property-file and property key fields are optional, you can instead specify values for only the 'value' and 'default value' fields

      1. I'm able to get the radio buttons without the property-file, yay!

        3 issues:

        • the 'Build' page is now greyed out with 'Loading' on top of it ... cannot trigger a build anymore. Removing the new input fixes it.
        • The values are showing twice for each radio button (Foo, Bar shows "Foo Foo" then "Bar Bar". Mostly cosmetic but could be confusing.
        • The area where the radio buttons are seem not high enough and I get the last few 3-4 pixels truncated at the bottom, and a scroll bar. Purely cosmetic.
        1. Stephane, which browser are you using? I have some java-script code that behaves differently on different browsers. I will try to reproduce the issues and fix them. 

          1. I've reproduced the same exact behavior on WebKit 6.0.2 (7536.26.17, 537+, Safari nightly builds), Chrome 24.0.1312.57, and Firefox 16.0.1 on Mac OS X.

          2. The blocking issue seem to be fixed with version 0.24. The other 2 cosmetic ones are still there, but I don't really care that much :-)

            Thanks for that awesome plugin.

            1. I have some fixes in 0.25 to fix the 3rd issue. For the 2nd issue I don't see the values showing twice on the radio button. Here is a screenshot of what i see.


              1. This is what I see with 0.24. Unfortunately we have a lot of jobs in the queue, some long running so I cannot update right now. I will try to apply 0.25 later tonight and let you know.

  17. Thanks for adding the radio buttons and check box options.  Like Stephane, I'm also seeing the values show up twice on the radio buttons:

    Also, if I add (2) radio button variables to my job, it treats them as a single radio button list when you go to select values.  IE - if I select a value for the 2nd radio button variable, the first variable returns an empty value.

    In the screenshot below, "radio" returns an empty string, while "radio 2" returns "clean", even though I have a default value of "debug" for radio.:

    I'm using build 0.26, running on Firefox.

    1. The issue with values showing up twice ghas been fixed and will be available in version 0.27. I still have to look into the other issue you described. I will update you soon

  18. Is there any possibility to choosing to customize the delimiter between choices (when multi-selecting)? My use case is to concatenate all the selections to construct a directory name to create.

    1. Isn't it possible to replace the commas with slashes in the build script?

      1. This is a release packaging build, so I am using the copy artifacts plugin to copy packages from several release builds already archived in jenkins into a common structure that automated deployment scripts can grab from.

        So yeah, I can create a script, but it will likely require me to find yet another plugin (likely the environment variable injection one) to make the path available to all the copy artifact jobs.

        Also, I don't want very deep nesting of folders, so I'd likely use underscores and create a single directory, not slashes.

        1. Could you open an issue for this in the issue tracker. 

  19. This does not work with Rebuild.

    I read that it should work with rebuild 1.17, even though rebuild is now at 1.19. I checked both and no luck.

    Will there be an answer to this?

  20. This is a very useful plugin and have been using with many of my projetcs! Thank you!

    Can I add a new feature? How about generating the list of values from a Scriptler or Groovy script? The ability to multi-select and get dynamic values would make this plugin even more powerful.

    Best

    -I-

    1. Hi Ioannis,

      I was thinking of adding the groovy script feature myself :) If you have already worked on this could you send me a git pull request for your changes. I would really appreciate that.

      Thanks
      Vimil

      1. Reviewing some of my old posts, I just realized that you have now implemented support for groovy generated choice values! Thank you, I got to try it!

        I think that the multi-select capability combined with the dynamic generation of options using groovy makes this plugin extremely useful. We have taken inspiration from your plugin to start a new enhanced multi-select capable plugin withBiouno called uno-choice.

        Uno-choice offers additional functionality required for more dynamic Jenkins UI forms used in bioinformatic applications, but overall these two plugins should offer great support for those that need a multi-select Jenkins UI control. Keep up the good work!

        Best regards

        Ioannis

  21. Hi,

    would be interested in what changed since v0.20?

    why would I upgrade?

  22. Hi,

    It would be great if we can have a parameter for providing some script that could be run as soon as i click on 'Build with Parameters'. A use case would be populating the 'Multi Select' parameter dynamically by using the property file that will get created by the script. I think there is a plugin for this functionality but there is no link to download the same.

    https://wiki.jenkins-ci.org/display/JENKINS/Extended+Choice+Parameter+Script+plugin (http://)

    Thanks

  23. Hi,

    Just wanted to thank the developers of the plugin. It's really useful and very complete.

    Keep up the good work!

  24. I tried hard but still cannot set up Multi-Level Single Select parameter. It is not clear. My Jenkins in on Linux, so, my file looks the following way:

    Suites \t Tests
    suite1 \t test1
    suite1 \t test2
    suite3 \t test3

    because tab-delimited AFAIU should look like this. I also specified in the "Value" field "Suites,Tests". Still I get an empty drop-down list. What am I doing wrong?

  25. Could you please give us a complete example of  Multi-Level Single/Multi Select with property file and a screenshot for parameters. I can't make it work.

    Thx

  26. I have exactly the same problem. I have Jenkins 1.565 and Extended Choice Parameter 0.32. I have tried Mozilla, IE and Chrome on both RedHat 6.4 and Windows 7 and I cannot get Multi Level select to work.

    First, if I don't select a default value checkbox then the save of the project fails with a json exception.

    If I do tick that box then the save succeeds but when I go to the build no dropdown is displayed. The name and description show but there's nothing displayed in between them.

    I also find that while configuring it warns about no property key which it shouldn't need for this type of selection, clicking back and forth between the file and key text boxes seems to clear that error.

    I've tried multiple file formats including the exact example given in the help and what seems to be suggested by the src code. Does anyone have a screenshot of this actually working? I'm starting to think this functionality just doesn't work? 

    1. There was a bug in version 0.32 which has been fixed in 0.34. Could you let me know if your still facing issues with this version?

      1. Hi Vimil, looks to be sorted now, many thanks!

  27. How do I actually use a groovy script to set the value/default? I tried println but that did not work.

    1. just do a

      return "a,b,c";

      to return a comma separated list of values.

      or

      return "a";

      to return a single value of 'a';

    2. just do a

      return "a,b,c";

      to return a comma separated list of values.

      or

      return "a";

      to return a single value of 'a'.

  28. Hi,

    I have some questions concerning this plugin:

    1) I have tried to create a properties file that has three level choice parameter but it does not work. The file looks like this:

    Country City Person

    United States   San Francisco

    United States   Chicago

    Mexico  Mexico City

    Mexico  Cancun

    United States   San Francisco   Joe

    United States   San Francisco   Linda

    United States   Chicago         Joe

    United States   Chicago         Linda

    Mexico  Mexico City     Joe

    Mexico  Mexico City    Linda

    Mexico  Cancun  Joe

    Mexico  Cancun  Linda

    and in the jenkins configuration I have wrote:

    Country,City,Person

    Should it work? Am I doing something wrong?

    2) Is there a way to have parameters types other the choice? I see that you are talking about getting values using a groovy script. How does it work?

    Thanks

    Gil

    1. Are you using tabs to separate the entries in the properties file and not spaces?

      for groovy script, you can either return a string such as "a,b,c" by typing return "a,b,c"; in the groovy script subsection for 'source for value' The values a,b,c are then displayed in a listbox, as checkboxes or radio buttons depending on what you chosen for the parameter type.

      1. Hi,

        I'm using tabs but anyhow I do not think this plugin can help me. 

        I have found external plugins (uno-choice-plugin) that can almost do what I want.

        Thanks for the help!

        Gil

  29. Hi, on the multi level single select where I have say, component and version, if make a selection, then deselect them back to the default, the variable gets set to "Select a version..." or "Select a component..." i.e. it doesn't get reset to blank. I also don't get a "remove" button. (Chrome)

    Also, on the multi level multi select I have a similar problem i.e. the remove button only appears against the first row when I add the second row, so once I've added the first row it can never be properly deselected again.

    Cheers, Richard.

  30. Hi, there seems to be a problem with encoding. I am reading Hebrew text from a property file. I have tried saving file with windows-1255 and utf-8 (and  many more) encoding, but values from the property file are still displayed in gibberish. 

    TIA for you help

  31. How can i extract selected value with groovy script?

    In property file option there's a key. What about groovy script..?

  32. Hi,

    I tried to implement the following example but didn`t work. Why?https://github.com/biouno/uno-choice-plugin/wiki/Uno-Choice-Cascade-Dynamic-Choice-Parameter
    (It`s a different plugin but i think extended choice plugin has all the capabilities to do the same)

    So i`d like to fill up some parameter based on the previous parameter selection. What do i need to implement the job creation on the fly? Groovy JavaScript or what?

    Thanks

  33. I'm getting nowhere trying to enumerate credentials in a Groovy script for a single choice parameter. All calls to com.cloudbees.plugins.credentials.CredentialsProvider are silently ignored. To be exact, I believe the calls are not ignored but fail with no diagnostics whatsoever.The same code works just fine in Jenkins script console.

    For example:

    import jenkins.*
    import jenkins.model.*
    import hudson.*
    import hudson.model.*
    this.class.classLoader.rootLoader.addURL( new URL("file:///local/home/baryca2/.jenkins/plugins/credentials/WEB-INF/lib/classes.jar") )
    def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
          com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class,
          Jenkins.instance, null, null );
    for (c in creds)

    Unknown macro: {       println(c.id + "}
    import jenkins.*
    import jenkins.model.*
    import hudson.*
    import hudson.model.*
    
    def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
          com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class,
          Jenkins.instance, null, null );
    
    String names = ""
    
    for (c in creds) {
           # println(c.description+ " : " + c.username)
           names += c.username + ","
    }
    names += "Anonymous"
    # println names
    return names&nbsp;
    

    I guess the script can't load the plugin class for some or the other reason, but I can't figure out why and how to make it do so.

    I'd appreciate any idea how to make it work....

    1. In case if anyone is interested, I got what I needed, i.e. a list of usernames and passwords from the credentials storage, by loading the credentials classes dynamically via plugin manager:

           def loader = Jenkins.instance.pluginManager.getPlugin("credentials").classLoader;
          def crprov = loader.loadClass("com.cloudbees.plugins.credentials.CredentialsProvider", true)
          def crusnm = loader.loadClass("com.cloudbees.plugins.credentials.common.StandardUsernameCredentials", true)
          def credentials = crprov.lookupCredentials(crusnm, Jenkins.instance, null, null );
      
  34. Hi,
    I use this plugin to create OS Cross Browser tests. So I have 4 dropdowns: operatingSistem, operatingSistemVersion, browser, browserVersion. I manage to configure the job just fine to have the 4 dropdowns but I cand not read the values from the first 3 dropdowns... I'm only getting the browserVersion value. 
    Please let me know how can I access the values from the first 3 dropdowns in order to use them as a JAR parameter in command line.
    Regards,
    Sorin

  35. Hi,
    I use this plugin to create OS Cross Browser tests. So I have 4 dropdowns: operatingSistem, operatingSistemVersion, browser, browserVersion. I manage to configure the job just fine to have the 4 dropdowns but I cand not read the values from the first 3 dropdowns... I'm only getting the browserVersion value. 
    Please let me know how can I access the values from the first 3 dropdowns in order to use them as a JAR parameter in command line.
    Regards,
    Sorin

  36. Hi,

    Am populating the property file with the following script

    #!/usr/bin/python

    with open('/home/walesa/example',' a') as file:
      file.write ("Country\tCity\n")
      file.write ("India\tChennai\n")
      file.write ("India\tChennai\n")
      file.write ("India\tChennai\n")
      file.write ("India1\tChennai1\n")
      file.write ("India1\tChennai1\n")

    With values being "Country,City"

    This gets only "Select the country" option and the city drop down box is not getting created.

    Can anyone help with what is wrong ? FYI my Jenkins server is on a Fedora 19.

    1. Could you try using spaces instead of tabs in your file

      1. My property file is as

        cat example
        Country City
        India Chennai
        India Chennai
        India Chennai
        India1 Chennai1
        India1 Chennai1

        If my Value is "County City" , I get "India Chennai" in the Scroll down box. No second column of drop down box when i select in the first.

        If my Value is "Country,City" , I get an empty drop down box.

  37. Hi,

    I have multiple jobs using the same groovy script, so I'm trying to use a Groovy Script File for the choice parameter rather than have the script in the config for every job. However trying to use the script as a file results in an unpopulated drop down box.

    Can anyone help with what is wrong? Does the file need to be in a specific place?

  38. I have set up a Multi-Level Single Select parameter called countryCity as per the example above

    Country City
    United States San Francisco
    United States Chicago
    Mexico Mexico City
    Mexico Cancun

    How do I get the selected value in the Country dropdown AND the City dropdown?

    At the moment, if I echo the value in a Windows batch command, it only prints the selected city.

  39. Hi,

    I'm trying to build a job through remote API like this:

    $.ajax({
    type: 'post',
    url: 'http://192.168.56.2:8080/job/TestJob/buildWithParameters/',
    data: {foo: 'bar', baz: true, bookmark: 'some-value'}
    })

    The "bookmark" parameter is created via Extended Choice Parameter plugin and it's always empty after that building process is completed, while other parameters get passed values.
    Am I doing something wrong or it's a bug?

    My Jenkins version is 1.589 and plugin version is 0.34

    Thanks

  40. I have set up a Multi-Level Single Select parameter called countryCity as per the example above

    Country City
    United States San Francisco
    United States Chicago
    Mexico Mexico City
    Mexico Cancun

    Name Test1

    Value Country,City

    How do I get the selected value in the Country dropdown AND the City dropdown?

    At the moment, if I echo the value in a sh command, it only prints the selected city in Test1 parameter.

    thank Zacky

    1. I'd also like to know how to get at the value of 'Country' in the usage example...ideally I want access to each of the options my user selects, not just the final option.

  41. When I add two complex type extended choice parameters to a job and save it, then go back to reconfigure it, the first parameter only displays fields for its name, description, and the radio buttons for whether its a simple or complex type parameter.  The complex type parameter radio button is selected as it should be.  The second extended choice parameter shows all the fields for the complex type parameter setting.    I can get the complex type fields for the first extended choice parameter to reappear by changing it from a complex type to a simple type and then back to a complex type (without saving).    I'm running Jenkins 1.594, with Extended Choice Parameter version 0.34.

  42. Please give a complete example of how to configure the Country<tab>City multi-select example, I get errors in the project configuration and an empty list.

    eg.
    /path/to/choice.props exists, but the provided key "Group,Project" doesnt exist in this property file.

    /path/to/choice.props exists exists, but you have to provide a property key as well.

    1. I eventually figured out how to use multi-select lists by trial-and-error.
      1. The "property" file is not like a Java properties file at all, just plain text with tab-delimited columns.  The first line contains tab-delimited column names.  So just like the "countries" example.

      2. Choose the radio "Complex Parameter Types" which is right down the bottom of the choices, when you select it all the options associated with "Simple Parameter Types" disappear.  Now you can choose "Multi-Level Multi-Select".

      3. In the "Property File" box enter the full path to your file (which is on the Jenkins master node in my case) .  I pinned the job to the Jenkins master node ("Restrict where this project can be run" Label expression: master).

      4. In the "Value" box enter your column headings, comma-separated.  So "Country,City" to follow the example.

      5. When the build is run, environment variable (named "ExtendedChoice" in my case) is set with the comma-separated values selected from the leaf (right-most) column.  So a comma-separated list of Cities in the example.  The list of values from the first column is not available, so if you wanted a wildcard ("ALL") for a country you'd need to name it something unique eg. "ALL (US)" and handle that in your script.

      1. 6. The property file must not contain any blank lines, otherwise no selections will be shown at all.

  43. Hi,

    Nice to see this plugin. It seems to me that it does not expand environment variables.

    Use case:

    I would like to centralize the possible choices in the configure system variables. So I create a variable called "myChoices" with the variables A,B,C

    In my job I configure an extended choice parameter with with the value = "$myCoices"

    Unfortunately it does not seem to work.

    Any suggestions for this?

    Best regards,

    Baubak

  44. Hi,

    I cannot set up Multi-Level Single Select parameter.
    I got the following properties file (separated with TABs, no empty line in it)

    Country City
    United_States   San_Francisco
    United_States   Chicago
    Mexico  Mexicoi_City
    Mexico  Cancun

    If my value is Country,City (comma separated) than i got empty list.

    If my value is Country City (space separated) i got "Select a country city..." and the whole list below:
    United_States   San_Francisco
    United_States   Chicago
    Mexico  Mexicoi_City
    Mexico  Cancun

    I can`t figure it out how to do what the help says: "Multi-Level Single Select: user chooses a selection from a drop down, and then a another drop down appears with selections that depend on the first value"

    Is there anybody how can use this plugin with Multi-Level Single Select ?

    OS: Linux
    Jenkins version: 1.616
    Plugin version: 0.43

    1. Ok, it was my fault. I edited the properties file with vim which use 4 spaces for tab. Recreated the properties file with geany and now everything works fine!

  45. Hi,

    Can you please give an example how to get the selected values when using JSON Parameter Config Groovy Script.

    with name variable i am able to all the values which i passed in the script not the values which i selected while building the project.

    Thanks

    1. You should use the json schema to specify the allowed values. Look at the link below for more details 

      https://github.com/jdorn/json-editor/blob/master/README.md#enum-values

      If you show me your groovy script I can understand the question better.

  46. HI

    In the JSON example given above how will i be able to use the updated values  as parameters in my job - please help.

    Thanks

    1. Tired some work around as there is no direct option available and it works for us. We get a JSON parameter as output, we later parse this JSON parameter with groovy json parser and we are able to get to retrive the required individual value/ parameter at the lowest granular level possible. Would be best if this logic is fed into the plugin and we are able to directly reference the individual parameters directly as part of our job configuration

      1. I think you can use the JavaScript config to add a beforeformsubmit handler that changes the value of the hidden field that holds the Json parameter output to the value you require.

  47. Hi,

    I have tried to use JSON parameter javascript config, but how can I get the "response" of my JSON shema in my build flow (as you can do a "return" of the JSON obtect with groovy) ?

    Can I use more than one schema in one paramter and get all their response ?

    Thanks

  48. Hi Vimal,

    Please also add a sample code snipped to print selected values in above json schema example? 

    Your help is greatly appreciated.

    Thank You!!

  49. Great plugin with rich functionality. But it has very bad UI settings. When I add only one parameter I got a lot of radiobuttons which are not grouped. (child params should indentation)  
    Its very difficult to configure job if one simple parameter -  "Basic Parameter Type" - occupy 1.8 of height of my screen. And this without expanding "Extended" properties!!   And when you add 2 more parameters of this type you'll completely lost in Configuration page. 

     - you'll got ~20 rows with options for it which occupy 1.5 height's of my monitor (1920x1200)

     

     Screenshot

  50. I have a configuration in JSON similar to the one above

    I have problems with 2 things:

    1. As I would like to have various environments configurations I created tabs and I would like to have a job parameterized based on chosen tab. The problem is getValue() function of json-editor returns all data. Can I somehow configure the editor to return only data from chosen tab?
    2. What is the best way to parse returned json? I am asking because the plugin returns whole json under one env variable and something like this: $
      Unknown macro: {environment.database.dbUrl}
      does not work.
    1. You can use the javascript  option to add an onsubmit event handler that sets the value of the bidden field to the value uou want.

      The value fir a specific tab can be retrieved using editor.getEditor (tabName).getValue ()

      I'll  send some sample code soon

  51. Hi,

    I have an issue with Default Groovy Script option.

    I am fetching some rows from the xml in Groovy Script and I am able to see them in check boxes or multi select and I want them to be checked all by default.

    But when I am pasting the same script in Default Groovy Script, only the first option is checked.

    Script I am using to fetch:

    groovy script
    File stream = new File('/var/lib/jenkins/test_stream.xml')
    def list = []
    stream.eachLine { line ->
      if ("$line" ==~ /^.*order.*/ && !line.split()[0].contains("!"))
      {  list.add("$line".split()[0] - /</) }
    }
    return list

    Thanks.

    1. Could you open a bug for this.

  52. I would like to understand if we can acheive my requirement using this plugin:
    I have with several columns in a text file. If I select Column1, then I would like to return all other column values in an array OR concatinated string in a specified format and return the string.
    Example:
    ParamProperties.txt:
    Name Address1 City State Zip
    John 1KaisyRd Newton MA 02030
    Kelly 3NelloreRd Weston MA 02032
    Now, I will select Name (John or Kelly), then it should return the parameter string as: 1KaisyRd-Newton-MA-02030.
    I would like to understand if we can acheive my requirement using this plugin:

    I have with several columns in a text file. If I select Column1, then I would like to return all other column values in an array OR concatinated string in a specified format and return the string.

    Example:

    ParamProperties.txt:

    NameAddress1CityStateZip

    John1KaisyRdNewtonMA02030

    Kelly3NelloreRdWestonMA02032

    Now, I will select Name (John or Kelly), then it should return the parameter string as: 1KaisyRd-Newton-MA-02030.

  53. Is anyone else experiencing issues with upgrade Version 0.61?

    After upgrading from Version 0.53 to Version 0.61 the plugin is passing 'null' to the javascript call for new JSONEditor(element, jsonObject).

    In Version 0.53 it was correctly passing the JSON String that is created by the fromJson(String s) groovy method.

    1. Patrick,

      Can you check if you are facing the issue in version 0.63?

      There was a bug in 0.61 that was fixed in 0.63

      1. Yes, I am seeing the issue in version 0.63.

        var editor_REPORT_SETTINGS = new JSONEditor(document.getElementById('editor_REPORT_SETTINGS_holder'), null);

        1. Can you checj if your groovy script is approved by going to in process approval section of jenkins

  54. Edit 2: Don't worry, I have forked and have selectize working as I would like.

    Is Selectize and/or Select2 available?

    Whilst using the JSON parameter feature.

    Also - is there any way to control the max size of a multiple select - it seems to max out at 10? Resolved this.

    Edit: I see that I can use Selectize on an array using type:array and format:selectize however none of my enum's are being picked up as options in a drop down - what is the correct formatting to apply choices this type of select?

    1. Hi. Can you please show example schema that will work with selectize in multiselect mode? I have tried many possible combinations from json-editor wiki and only slution that worked for me is to make additional selectize multi select field filled with default values and watch it from actual field that i need to fill with variants. But I dont want to create additional field for this.

      1. I forked repo and changed some of the javascript and rebuilt plugin to work for what I wanted.

        Do you mean that you can't make selectize work in the plugin in Jenkins or on here http://jeremydorn.com/json-editor/? What's your schema at the moment?

        1. Thank you for your reply) 

          After my comment I experimented a little in local copy of json-editor repository, since selectize is disabled in demo page. And I was not able to make selectize work with any of the patterns described in "Enum" section of readme from repo. So I suspect selectize support is limited in editor.

          Right now my schema looks like this (with goovy script): 

          import org.boon.Boon;
          
          def jsonEditorOptions = Boon.fromJson(/{
            disable_edit_json: true,
            disable_properties: true,
            no_additional_properties: true,
            disable_collapse: true,
            disable_array_add: true,
            disable_array_delete: true,
            disable_array_reorder: true,
            theme: "bootstrap3",
            show_errors: "always",
            iconlib: "fontawesome4",
            schema: {
              "type": "object",
              "title": "",
              "properties": {
                "groups_def": {
                  "type": "array",
                  "description": "Test groups to run. Group set acts like filter - only tests that belongs to all selected groups will run.",
                  "format": "selectize",
                  "default": ["api","gui"]
                },
                "groups_sel": {
                  "type": "array",
                  "description": "Test groups to run. Group set acts like filter - only tests that belongs to all selected groups will run.",
                  "format": "selectize",
                  "enumSource": "def",
                  "watch": {
                    "def": "root.groups_def"
                  }
                }
              }
            }
          }/);

          This way I got group_def working with selectize, but all variants is selected by default. And what I want is group_sel behavior, when selection variants displayed on click, but without dependency on another field.

          1. I've had a look at the json-editor javascript this plugin uses and it is not good enough to do what you want - It will just not work as it is broken.

            If you are able to I would recommend getting the most recent json-editor distribution from jdorn's github page and rebuilding this plugin and using that instead - It will allow you to do what you want.

            1. Thank you for your help). I will try that.

  55. I install the plugin in jekins, and it works well

    And I install 0.44 version in hudson 3.3.3, it can't work well

    I wonder what hudson version is supported by this plugin ?

    Thanks

    Jackie

  56. Can we get sandbox support for Groovy scripts? I have jobs created by JobDSL that change the groovy script values often and manual approval is an overhead.

  57. When i use Parameter type: Text Box i expect to see all my values populated inside the box instead the box is empty.

    How can i have all my values from file checked by default?

  58. Hello,

    I'm using Property File, insert path that include global property: $

    Unknown macro: {NETWORK_PATH}

    \Tools\Jenkins PropertyFiles\BuildLocations.properties

    Getting warning: $

    \Tools\Jenkins PropertyFiles\BuildLocations.properties doesnt seem to exist.

    Can I use global property within property file?

    Thanks a lot

  59. Hello,

    I'm using Property File, insert path that include global property: ${NETWORK_PATH}\Tools\Jenkins\PropertyFiles\BuildLocations.properties

    Getting warning: ${NETWORK_PATH}\Tools\Jenkins PropertyFiles\BuildLocations.properties doesnt seem to exist.
    Can I use global property within property file?

    Thanks a lot

  60. Is there a way to use the extended parameter choice from pipeline as code (jenkinsfile)?  I'm trying to replicate a freestyle job in a multibranch pipeline.

    1. If you are trying to use it in an input step you can create an instance of ExtendedChoiceParameterDefinition and add it to the parameters list of the input.

      import com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition
      
      def type = "PT_JSON"
      def groovyScript  = null
      def propertyValue  = null
      def projectName = null
      def propertyFile = null
      def groovyScriptFile = "/path_to/script.groovy"
      ... 
      def extendedChoice = new ExtendedChoiceParameterDefinition(name,
      			type,
      			propertyValue,
      			projectName,
      			propertyFile,
      			groovyScript,
      .....
       
      input message: 'Param1', parameters: [extendedChoice]
       

       

       

      1. Thanks Lionel Orellana.  Is it possible to add this to the parameters list instead of the input list.  

        Our build jobs currently requires build parameters.  What we are attempting to do is move the ExtendedChoiceParameter into the parameters section to obtain the same functionality that the Jenkins UI is capable of currently.

        For example:

        parameters { 
          string(name: 'Version', defaultValue: '1.0', description: 'Current Version')
          text(name: 'Param1', defaultValue: '', description: 'Text parameter 1')
          booleanParam(name: 'Param2', defaultValue: false, description: 'Boolean parameter 2')
          choice(name: 'Param3', choices: 'Choice1\nChoice2', description: 'Choose parameter 3?')
          extendedChoice(?)
        }

         

        I believe I already know this is not implemented currently.  Just curious. 

         

         

        1. Should work the same way.

          def extendedChoice = new ExtendedChoiceParameterDefinition(name,
          .....
          parameters { 
           extendedChoice
          }
           
          1. Hi @Lionel Orellana

            I followed this, but I'm getting rejected by sandbox like this. But there is nothing on in-script approval page.

             

            Have you approved this when you run?

             

            org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified new com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition java.lang.String null java.lang.String null null java.lang.String null null null null null null null null null null null null null null null null null null null java.lang.Boolean java.lang.Boolean null null null
            	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onNewInstance(SandboxInterceptor.java:126)
            1. Yes I have something like that in my approvals. 

               

            2. I removed all my approvals and it still works. 

              I believe it's because I create the ExtendedChoiceParameterDefinition in a script in the global library.

    2. According to this stackoverflow, you can use:

      properties([
              buildDiscarder(
                  logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '5')), 
                  parameters([
                          [$class: 'ExtensibleChoiceParameterDefinition', 
                              choiceListProvider: [
                                 $class: 'TextareaChoiceListProvider', 
                                 choiceListText: 'foo\nbar',
                                 defaultChoice: 'bar',
                                 addEditedValue: false,
                             ], 
                             description: 'blah blah blah blah', 
                             editable: true, 
                             name: 'choose_mnt'
                          ], 
                          booleanParam(defaultValue: false, description: '[TO DO]', name: 'include_installers')
                      ]), 
                      pipelineTriggers([])
                  ])
  61. Hi,

    I am using the "Extended-Choice Parameter" with "JSON Parameter Config Groovy Script".

    I want to chose a Server from a dropdown list, which works pretty fine.

    "title": "Server",
    "headerTemplate": "{{self.name}}",
    "type": "array",
    "format": "dropdown",

    How can I get the index from this dropdown lis? Is there a possibility?

    Thanks a lot

     

  62. Hi,

    I'm trying to use the "JSON Parameter Config Groovy Script" with a Pipeline script. I'm trying to define this as an input parameter.

    The groovy script that defines the JSON is checked out from Git along with the Jenkinsfile. The structure is flat. The script is right next to the Jenkinsfile.

    /Jenkinsfile
    /def-choice.groovy

    I specify the groovyScriptFile property

    groovyScriptFile = def-choice.groovy

    and I also set

    projectName = env.JOB_NAME

    because I looked at the code and it's apparently mandatory in order for the job to load the script file.

    This somehow doesn't really work. It doesn't define anything. I've seen a post here saying

    return "a,b,c"

    is a valid script. It didn't work for me. So I'm actually copying fro the groovy script examples above and pasting this into the script. Is this correct?

    So, two questions:

    1) Where should I place the script and what should it look like? Is it not just like the groovy scripts above?

    2) Then, even when I defined my script in the actual field, rather than from the pipeline code, the parameters of type boolean are rendered as dropdowns with true and false options. I'd like checkboxes instead. I saw in previous posts that checkboxes are supported, how do I specify I want my booleans rendered as such from the Groovy script?

  63.  No doubt this plugin is immensely powerful & handy.

    I used  "JSON Parameter Config Groovy Script" option to built something like this(data is read dynamically from file using Java callout),

     

    Now in my JOB UI, there should be another DropDown as Application Type with values SOA/OSB.

     If I select SOA from that Drop down, above Job details should display SOA related details only(first 2 records). Basically an ajax call is what I am looking for. 

    In this page itself there is similar thing done using template,

    "template""{{fname}} {{lname}}",

    Is there a way to invoke a Java call to reload the content? Any other approach/suggestion?

  64. I have a parameter that uses the "JSON Parameter Config Groovy Script" option for specifying all the parameters.

    Can i specify a text parameter to by displayed with a multiline textbox?

  65. I am struggling  to get a simple pass a parameter to Groovy on my pipeline. Could someone give me a hand to know how to  inject the JSON output to my Pipeline (Groovy).

     

    This is what I have on my JSON Parameter Config Groovy Script:

     

    import org.boon.Boon;

    def jsonEditorOptions = Boon.fromJson(/{
    disable_edit_json: true,
    disable_properties: true,
    no_additional_properties: true,
    disable_collapse: true,
    disable_array_add: true,
    disable_array_delete: true,
    disable_array_reorder: true,
    show_errors: "always"
    theme: "bootstrap3",
    iconlib:"fontawesome4",
    schema: {
    "title": "Save Artifacts Externally?",
    "oneOf": [
    {
    "title": "No",
    "type": "null",
    "options": {
    "disable_collapse": true,
    "disable_edit_json": true,
    "disable_properties": true,
    "theme": "bootstrap3",
    "show_errors": "always"
    }
    },
    {
    "title": "Yes",
    "type": "object",
    "properties": {
    "copypathType": {
    "title": "Path",
    "type": "string"
    }
    }
    }]
    }
    }/);

    return jsonEditorOptions;

    1. {

          disable_edit_json: true,

          disable_properties: true,

          no_additional_properties: true,

          disable_collapse: true,

          disable_array_add: true,

          disable_array_delete: true,

          disable_array_reorder: true,

          show_errors: "always",

          theme: "bootstrap3",

          iconlib: "fontawesome4",

          schema: {

              "title": "Save Artifacts Externally?",

              "oneOf": [{

                  "title": "No",

                  "type": "object",

                  "options": {

                      "disable_collapse": true,

                      "disable_edit_json": true,

                      "disable_properties": true,

                      "theme": "bootstrap3",

                      "show_errors": "always"

                  }

              },

              {

                  "title": "Yes",

                  "type": "object",

                  "properties": {

                      "copypathType": {

                          "title": "Path",

                          "type": "string"

                      }

                  }

              }]

          }

      }

      1. James Withers thx for your reply. Could you provide  the Groovy code (pipeline) that will retrieve the parameter   "copypathType" that is the part that I am not able to figure it out .  BTW I replace "null" for "object" my mistake.

        1. If the name of the Extended Choice Parameter is PARAM

          Then you can access the param like "env.PARAM"

          You can use the pipeline step readJSON (must be in node) and then access that object like a map using dot notation.

          println(env.PARAM)
          node {
              def jsonArr = readJSON(text: env.PARAM)
              println("${jsonArr}")
              println("${jsonArr.copypathType}")
          }
          1. Thanks a lot James. It work like a charm

  66. Extended Choice Parameter: can it be reactive?

    Im trying to render dinamically some parameters in jenkins. I have achieved it with this nice extended parameter plugin using extended choice parameter.

    My problem now is that the control had to be reactive to another parameter. (Something similar as Active Choice Reactive Parameter, where you specify what other parameter force it refresh and you can use the other parameter name as a variable name of the value choosen in your groovy script).

    Does anybody know how can you make extended choice parameter to be reactive and change behabiour depending on other parameters value?

  67. Extended Choice Parameter: can it be reactive?

    im trying to render dinamically some parameters in jenkins. I have achieved it with extended parameter plugin using extended choice parameter.

    My problem now is that the control had to be reactive to another parameter.(something similar as Active Choice Reactive Parameter, where you specify what other parameter force it refresh and you can use the other parameter name as a variable of choosen vale in your groovy script).

    Does anybody know how can you make extended choice parameter to be reactive and change behabiour depending on other parameters value?

    1. Have you tried json parameter with tabs as high level parameter?

  68. I was wondering if is possible to expand the Jenkins variables? This is what I am trying to do

    "properties": {
        "SubjectType": {
        "title": "Subject",
        "type": "string",
         "default": "The Jenkins build ${BUILD_NUMBER} is ready"
         }

    .

    .

    }

     

  69. something that will be nice is to be able to hid the parameter name from been displayed

    1. "title": " "

      This works on the jdorn editor's test page - haven't tested on Jenkins.

  70. Hi there,

    Can anybody tell me how to use the oneOf property and how to set the value in startvalue.

    Daniel

  71. Hi guys,

    The plugin is great! But there are some problems - 

    I have 0.76 version of Extended Choice Parameter and Rebuilder plugin v 1.27.

    when using json parameter rebuild option doesn't provide me exactly the same UI.

    When first build:

    When rebuild:

    will you support this feature?

    Or can somebody suggest another way to organize dynamic change of input parameters with respect to some high level param?

  72. Html is not working in Description on Jenkins 2.98 with latest Extended Choice Parameter Plugin, can you fix it.

  73. Hi all,

     

    sorry for a very noob question since I don't understand much on Groovy.

    based on the watched fields example above, how can I get the first_name variable as environment variable used in the build process?

    1. using the parameter value in batch command

    I have a build step in batch command which is using variable set in general.

    in this case when I pass the extended choice parameter name to the batch command as %CHOICE1%, the value returned is the JSON file path.

    How can I get the first_name or last_name value defined in the parameter?

           2. using parameter in the build step

    secondly I want to use "first_name" parameter as a folder name created by File Operations plugin

     

    thank you very much.

  74. Hi,

    is it possible to use global shared libraries for JSON Parameter Config Groovy Script?

    Thanks,
    Chris

  75. Have a look at htmlresource plugin for this functionality

  76. Hi,

    I have created simple list named 'ENVIRONEMNT' with key-value as following:

    valuedescription
    1one
    2two
    3three

     

    So everything is fine and working OK... BUT I need to access selected description variable. If I use ${ENVIRONEMNT} I obtain the 'value' (as normal behaviour) ... but in different place I need to have 'description' value ... . Is there any way how to access description? .. smth like that ... ${ENVIRONMENT.description} 

     

    Thanks,

    ivan

  77. I tried a simple example using the json parameter type option using the following groovy script(as provided in above doc) :

    import org.boon.Boon;
     
    def jsonEditorOptions = Boon.fromJson(/{
            disable_edit_json: true,
            disable_properties: true,
            no_additional_properties: true,
            disable_collapse: true,
            disable_array_add: true,
            disable_array_delete: true,
            disable_array_reorder: true,
            theme: "bootstrap2",
            iconlib:"fontawesome4",
            schema: {
              "type": "object",
              "title": "Name",
              "properties": {
                "first_name": {
                  "type": "string",
                  "propertyOrder" : 1
                },
                "last_name": {
                  "type": "string",
                  "propertyOrder" : 2
                },
                "full_name": {
                  "type": "string",
                  "propertyOrder" : 3,
                  "template": "{{fname}} {{lname}}",
                  "watch": {
                    "fname": "first_name",
                    "lname": "last_name"
                  }
                }
              }
            },
            startval: {
                "first_name" : "John",
                "last_name" : "Doe",
                "full_name" : "John Doe"
            }
    }/);
    I am not getting the parameters as the environment variables. Basically, I want to echo the parameters passed to my job i.e expecting to get when I do echo "$first_name" in execute shell should return John. But it is not working for me. Could you please help me how can I access the parameters in the job. Or do I need to use the groovy script to access the parameters. If yes, could you share the groovy code snippet to access parameters as environment variables (smile) 
  78. Figure I would share this for anyone trying to generate forms using JSON parameter via groovy script in a pipeline. Hope it helps.

    import com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition
    
    node(){
        def parameterList = []
        def inputAsMap = [
            disable_edit_json: false,
            disable_properties: true,
            no_additional_properties: true,
            disable_collapse: true,
            disable_array_add: true,
            disable_array_delete: true,
            disable_array_reorder: true,
            theme: "bootstrap2",
            iconlib:"fontawesome4",
            schema:[:]
        ]
        inputAsMap.schema = [
            type: "object",
            format: "tabs",
            title: "Data",
            properties: [
                projects: [
                    type: "object",
                    title: "Project Query",
                    propertyOrder: 1,
                    properties:[
                        generate: [
                            type: "boolean",
                            propertyOrder: 1
                        ],
                        id:[
                            type: "string",
                            propertyOrder : 2
                        ]
                    ]
                ]
            ]
        ]
        inputAsMap.startval = [
            projects : [
                generate : false,
                id : ".*"
            ]
        ]
        def asJson = { obj ->
            def jsonBuilder = new groovy.json.JsonBuilder(obj)
            return jsonBuilder.toString()
        }
        def jsonText = asJson(inputAsMap)
        def jsonGroovyScript = """
            import org.boon.Boon;
            def jsonEditorOptions = Boon.fromJson(/\${jsonText}/);
            return jsonEditorOptions
        """
        def jsonParams = new ExtendedChoiceParameterDefinition(
            'form', //String name,
            'PT_JSON', //String type,
            null, //String value,
            null, //String projectName,
            null, //String propertyFile,
            jsonGroovyScript, //String groovyScript,
            null, //String groovyScriptFile,
            "jsonText=$jsonText", //String bindings,
            '', //String groovyClasspath,
            null, //String propertyKey,
            null, //String defaultValue,
            null, //String defaultPropertyFile,
            null, //String defaultGroovyScript,
            null, //String defaultGroovyScriptFile,
            null, //String defaultBindings,
            null, //String defaultGroovyClasspath,
            null, //String defaultPropertyKey,
            null, //String descriptionPropertyValue,
            null, //String descriptionPropertyFile,
            null, //String descriptionGroovyScript,
            null, //String descriptionGroovyScriptFile,
            null, //String descriptionBindings,
            null, //String descriptionGroovyClasspath,
            null, //String descriptionPropertyKey,
            null, //String javascriptFile,
            null, //String javascript,
            false, //boolean saveJSONParameterToFile,
            false, //boolean quoteValue,
            5, //int visibleItemCount,
            '', //String description,
            ',' //String multiSelectDelimiter
        )
        parameterList << jsonParams
     
        def form = input(
            id: 'form', message: 'input parameters', parameters: parameterList
        )
    }
    
    
Write a comment…