In my Jenkins job I return a string parameter such as that:
capacity/pool_capacity.suite capacity/volume_capacity.suite
In a Groovy script I use collect and join in order to add a prefix and join each string:
suite_file_name = suite_file_name.collect{ "-f suites/$it" }.join(" ")
In the actual output, I get the prefix for each character in the string that I return from Jenkins:
-f suites/c -f suites/a -f suites/p -f suites/a -f suites/c -f suites/i -f suites/t -f suites/y -f suites// -f suites/p -f suites/o -f suites/o -f suites/l -f suites/_ -f suites/c -f suites/a -f suites/p -f suites/a -f suites/c -f suites/i -f suites/t -f suites/y -f suites/. -f suites/s -f suites/u -f suites/i -f suites/t -f suites/e -f suites/ -f suites/c -f suites/a -f suites/p -f suites/a -f suites/c -f suites/i -f suites/t -f suites/y -f suites// -f suites/v -f suites/o -f suites/l -f suites/u -f suites/m -f suites/e -f suites/_ -f suites/c -f suites/a -f suites/p -f suites/a -f suites/c -f suites/i -f suites/t -f suites/y -f suites/. -f suites/s -f suites/u -f suites/i -f suites/t -f suites/e
Eventually, I want to have an output such as that:
-f suites/capacity/pool_capacity.suite -f suites/capacity/volume_capacity.suite
What am I doing wrong?
CodePudding user response:
You have to first split
the string and then collect.
suite_file_name.split(" ").collect{ "-f suites/$it" }.join(" ")
CodePudding user response:
Divided my answer to 2 parts:
suite_file_name = suite_file_name.toString().split(" ")
suite_file_name = suite_file_name.collect{ "-f suites/$it" }.join(" ")