1

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?

2 Answers 2

2

You have to first split the string and then collect.

suite_file_name.split(" ").collect{ "-f suites/$it" }.join(" ") 
Sign up to request clarification or add additional context in comments.

Comments

0

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(" ") 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.