Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Bug in handling } in dynamic values #3562

bioandras ·
Hi!

I think I have found a bug in script evaluation. I'm trying to do some more complex computation in a scripted parameter: I have a step with a computed value for the repeat parameter. The below scripts are made up to illustrate the bug:

If I set this to the repeat parameter:
${groovy: def sum = 0; def values=[1,2,3]; for (int i : values) sum += i; if (sum < 6) { return "a" \} else return "b" }

then the script works as expected (I get a single run with "b" as the parameter).

However as soon as I try to add curly braces around the loop block in there like this:
${groovy: def sum = 0; def values=[1,2,3]; for (int i : values) { sum += i; \} if (sum < 6) { return "a" \} else return "b" }

execution breaks with the following error message:
ERROR - Step 'master>Clean Build Storage (Steps)' is failed: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
script14668208906131000868311.groovy: 1: expecting EOF, found 'if' @ line 1, column 70.
int i : values) { sum += i; } if (sum <
^


This seems to happen with any kind of block (for loop, each, generic closures) except for the if/else blocks.
  • replies 2
  • views 1937
  • stars 0
robinshen ADMIN ·
You should insert either a line break or ";" before if statement; otherwise it is not a valid groovy script

${groovy: def sum = 0; def values=[1,2,3]; for (int i : values) { sum += i; \}
if (sum < 6) { return "a" \} else return "b" }
bioandras ·
Wow, my bad - thanks for spotting it!