[JIRA] (JENKINS-58219) Active Choices Reactive Parameter Groovy script returning String instead of List

9 views
Skip to first unread message

bhand14@protonmail.com (JIRA)

unread,
Jun 26, 2019, 2:41:02 PM6/26/19
to jenkinsc...@googlegroups.com
Brett Hand created an issue
 
Jenkins / Bug JENKINS-58219
Active Choices Reactive Parameter Groovy script returning String instead of List
Issue Type: Bug Bug
Assignee: Bruno P. Kinoshita
Components: active-choices-plugin
Created: 2019-06-26 18:40
Environment: Active Choices plugin version 2.1
Jenkins version 2.164.1
Labels: jenkins pipeline plugins
Priority: Minor Minor
Reporter: Brett Hand

I have an Active Choices parameters defined: It is an Active Choices Reactive parameter, where I am simply returning a list of character strings via the Groovy script (i.e: return ['example1','example2']) that will be used to create some check boxes. I notice from the documentation that the way I have formatted this should return an ArrayList. I have also verified that this does return an ArrayList in a Groovy web console.

Now, the problem occurs when I attempt to index the list later on in my Jenkinsfile. If my list contained ["example1","example2"], then list[0] would return "e" instead of "example1". It looked like my list was actually a String instead. I debugged the parameter and found that it actually was a String type.

I am wondering why my parameter is being returned as a String instead of a list, as it appears that the way I have set it up should return a list, which I should then be able to index.

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

bhand14@protonmail.com (JIRA)

unread,
Jun 26, 2019, 2:42:01 PM6/26/19
to jenkinsc...@googlegroups.com
Brett Hand updated an issue
Change By: Brett Hand
I have an Active Choices parameters parameter defined: It is an Active Choices Reactive parameter, where I am simply returning a list of character strings via the Groovy script (i.e: return ['example1','example2']) that will be used to create some check boxes. I notice from the documentation that the way I have formatted this should return an ArrayList. I have also verified that this does return an ArrayList in a Groovy web console.


Now, the problem occurs when I attempt to index the list later on in my Jenkinsfile. If my list contained ["example1","example2"], then list[0] would return "e" instead of "example1". It looked like my list was actually a String instead. I debugged the parameter and found that it actually was a String type.


I am wondering why my parameter is being returned as a String instead of a list, as it appears that the way I have set it up should return a list, which I should then be able to index.

 

bhand14@protonmail.com (JIRA)

unread,
Jun 26, 2019, 2:50:02 PM6/26/19
to jenkinsc...@googlegroups.com
Brett Hand commented on Bug JENKINS-58219
 
Re: Active Choices Reactive Parameter Groovy script returning String instead of List

I also suspected the parameter was actually a String because I was able to use the tokenize() method on it. I would not be able to do this if the returned parameter were a List.

bhand14@protonmail.com (JIRA)

unread,
Jun 26, 2019, 3:00:02 PM6/26/19
to jenkinsc...@googlegroups.com
Brett Hand updated an issue
Change By: Brett Hand
I have an Active Choices parameter defined: It is an Active Choices Reactive parameter, where I am simply returning a list of character strings via the Groovy script (i.e: return ['example1','example2']) that will be used to create some check boxes. I notice from the documentation that the way I have formatted this should return an ArrayList List . I have also verified that this does return an ArrayList List in a Groovy web console.


Now, the problem occurs when I attempt to index the list later on in my Jenkinsfile. If my list contained ["example1","example2"], then list[0] would return "e" instead of "example1". It looked like my list was actually a String instead. I debugged the parameter and found that it actually was a String type.

I am wondering why my parameter is being returned as a String instead of a list, as it appears that the way I have set it up should return a list, which I should then be able to index.

 

bhand14@protonmail.com (JIRA)

unread,
Jun 26, 2019, 3:01:03 PM6/26/19
to jenkinsc...@googlegroups.com
Brett Hand updated an issue
I have an Active Choices parameter defined: It is an Active Choices Reactive parameter, where I am simply returning a list of character strings via the Groovy script (i.e: return ['example1','example2']) that will be used to create some check boxes. I notice from the documentation that the way I have formatted this should return an List. I have also verified that this does return an List in a Groovy web console.

Now, the problem occurs when I attempt to index the
list List later on in my Jenkinsfile. If my list List contained ["example1","example2"], then list[0] would return "e" instead of "example1". It looked like my list List was actually a String instead. I debugged the parameter and found that it actually was a String type.

I am wondering why my parameter is being returned as a String instead of a
list List , as it appears that the way I have set it up should return a list List , which I should then be able to index.

 

bhand14@protonmail.com (JIRA)

unread,
Jun 26, 2019, 3:22:02 PM6/26/19
to jenkinsc...@googlegroups.com
Brett Hand updated an issue
I have an Active Choices parameter defined: It is an Active Choices Reactive parameter, where I am simply returning a list of character strings via the Groovy script (i.e: return ['example1','example2']) that will be used to create some check boxes. I notice from the documentation that the way I have formatted this should return an a List. I have also verified that this does return an a List in a Groovy web console.

Now, the problem occurs when I attempt to index the List later on in my Jenkinsfile. If my List contained ["example1","example2"], then list[0] would return "e" instead of "example1". It looked like my List was actually a String instead. I debugged the parameter and found that it actually was a String type.

I am wondering why my parameter is being returned as a String instead of a List, as it appears that the way I have set it up should return a List, which I should then be able to index.

 

imoutsatsos@msn.com (JIRA)

unread,
Sep 11, 2019, 11:55:02 AM9/11/19
to jenkinsc...@googlegroups.com
Ioannis Moutsatsos commented on Bug JENKINS-58219
 
Re: Active Choices Reactive Parameter Groovy script returning String instead of List

Brett Hand AC parameters have not been tested in use with Jenkinsfile and we only have experience using them in 'freestyle' type builds. Nonetheless, in these cases returning a  list of Strings is required for proper display in the build form UI. The parameters are passed to the build as text with the selected options as a comma separated String. You may need to tokenize this string to return a list. Note that 'splitting' a string with Groovy returns a String[] not a list

I hope this helps. And any experience with using AC parameters in jenkinsfile is always useful (for future reference). Thank you!

This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages