blob: 2c1986f3dfd5716f2a0171bd7c86534d4b789d5a [file] [log] [blame]
Sergey Kulanov1bbd3612016-09-30 11:40:11 +03001package ci.mcp
2
3/**
4 * https://issues.jenkins-ci.org/browse/JENKINS-26481
5 * fix groovy List.collect()
6 * Build command line options, e.g:
7 * cmd_opts=["a=b", "c=d", "e=f"]
8 * key = "--build-arg "
9 * separator = " "
10 * def options = getCommandBuilder(cmd_opts, key, separator)
11 * println options
12 * > --build-arg a=b --build-arg c=d --build-arg e=f
13 *
14 * @param options List of Strings (options that should be populated)
15 * @param keyOption key that should be added before each option
16 * @param separator Separator between key+Option pairs
17 */
18
19@NonCPS
20def getCommandBuilder(ArrayList options, String keyOption, String separator = " ") {
21 return options.collect{ keyOption + it }.join(separator).replaceAll("\n", "")
22}