如何将参数字符串转换为大写并在我的Jenkins文件中使用?
def parameters = [:]
// I get all the parameters from an ini file here and one of the parameter 'NAME' has its value in lowercase.
stage('example')
{
echo 'converting parameter to uppercase'
def a = ${parameters['NAME']}.toUpperCase()
echo "${a}";
bat "example.bat arg1 ${a}"
}
// THis is giving me some huge error when I run my Jenkins job with these lines in my file
答案 0 :(得分:0)
怎么了?
可能:Groovy不确定“ $ {parameters ['NAME']}”是否为字符串。首先尝试强制执行,然后执行.toUpperCase:
def a = $ {parameters ['NAME']}。toString()。toUpperCase();
或
def a = parameters ['NAME']。toString()。toUpperCase();
答案 1 :(得分:0)
$ {}是字符串插值所必需的。以下链接应有帮助。
http://docs.groovy-lang.org/latest/html/documentation/#_string_interpolation