Using Groovy script to set 'Extended Choice Parameter'

2,579 views
Skip to first unread message

Milan Satpathy

unread,
May 21, 2015, 8:54:08 AM5/21/15
to jenkins...@googlegroups.com
Hi,

I am relatively new to jenkins. I am trying to use 'Extended Choice parameters' to display a list of values for the second parameter, depending upon first parameter value.

Example: The date values to be displayed depend on the month you have choosen.

First Valiable: MONTH
Range: 1..12

Groovy Script for second variable:
-------------------------------------------------
MONTH=binding.variables.get('MONTH')

if ((MONTH == 1) || (MONTH == 3) || (MONTH == 7) ||(MONTH == 8)|| (MONTH == 10))
{
   return 1..31
}
else if (MONTH == 2)
{
  return 1..28
}
else
{
  return 1..30
}

Result: Always 1..30, i.e. the else condition irrespective of what value is set for first parameter. Can anyone suggest how to get it right?
Also is there a way to debug it?

Thanks in advance!

Milan


Reply all
Reply to author
Forward
0 new messages