如何将 Jenkins 管道中的所有参数转换为小写。类似于trim,是否有一个属性可以作为参数声明的一部分添加,
对于修剪,我有如下内容,
parameters {
string defaultValue: '', description: 'Some dummy parameter', name: 'someparameter', trim: true
}
在我的管道工作中,我有 10 多个字符串参数,并希望将它们全部转换为小写
最佳答案
这是一种方法:
pipeline {
agent any
parameters {
string ( name: 'testName', description: 'name of the test to run')
}
stages {
stage('only') {
environment {
TEST_NAME=params.testName.toLowerCase()
}
steps {
echo "the name of the test to run is: ${params.testName}"
sh 'echo "In Lower Case the test name is: ${TEST_NAME}"'
}
}
}
}
关于groovy - Jenkins 管道将所有参数转换为小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56819405/