groovy - Jenkins 管道将所有参数转换为小写

标签 groovy parameters jenkins-pipeline jenkins-groovy

如何将 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/

相关文章:

groovy - 在 Groovy DSL 中使用 'owner' 属性

delphi - 在 ADOQuery 中使用参数时出错

Django,从request.GET中排除参数

c - 将无符号字符数组作为参数传递 - 数组未正确传递

java - Jenkinsfile 写入 JSON 文件

jenkins - 从Jenkins管道检查gradle子项目是否存在

grails - 安装Grails Drools插件时涉及的手动步骤

gradle - groovy/gradle插件无法有条件地构建

http - 我在使用 wget 时收到 cookie,但在使用 groovy 脚本时没有收到 cookie

Jenkins 管道 : Shouldn't closures resolve variables the same inside parallel as outside?