Sergey Kulanov | 1bbd361 | 2016-09-30 11:40:11 +0300 | [diff] [blame^] | 1 | package 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 |
| 20 | def getCommandBuilder(ArrayList options, String keyOption, String separator = " ") { |
| 21 | return options.collect{ keyOption + it }.join(separator).replaceAll("\n", "") |
| 22 | } |