Ruslan Kamaldinov | 90d4e67 | 2016-11-11 18:31:00 +0300 | [diff] [blame] | 1 | package com.mirantis.mcp |
| 2 | |
| 3 | /** |
| 4 | * https://issues.jenkins-ci.org/browse/JENKINS-26481 |
| 5 | * fix groovy List.collect() |
| 6 | **/ |
| 7 | @NonCPS |
| 8 | def constructString(ArrayList options, String keyOption, String separator = " ") { |
| 9 | return options.collect { keyOption + it }.join(separator).replaceAll("\n", "") |
| 10 | } |
| 11 | |
| 12 | /** |
| 13 | * Generate current timestamp |
| 14 | * |
| 15 | * @param format Defaults to yyyyMMddHHmmss |
| 16 | */ |
| 17 | def getDatetime(format = "yyyyMMddHHmmss") { |
| 18 | def now = new Date(); |
| 19 | return now.format(format, TimeZone.getTimeZone('UTC')); |
Denis Egorenko | 8c60655 | 2016-12-07 14:22:50 +0400 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Run tox with or without specified environment |
| 24 | * @param env String, name of environment |
| 25 | */ |
| 26 | def runTox(String env = null) { |
| 27 | if (env) { |
| 28 | sh "tox -v -e ${env}" |
| 29 | } else { |
| 30 | sh "tox -v" |
| 31 | } |
| 32 | } |