Jenkins 管道将所有参数转换为小写 [英] Jenkins pipeline convert all parameters to lowercase

查看:31
本文介绍了Jenkins 管道将所有参数转换为小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 Jenkins 管道中的所有参数转换为小写.与 trim 类似,是否有一个属性可以作为参数声明的一部分添加,

How can I convert all the parameters in a Jenkins pipeline to lowercase. Similar to trim, is there an attribute that one could add as part of the parameter declaration,

对于修剪,我有类似下面的内容,

For trim, I have something like below,

parameters {
   string defaultValue: '', description: 'Some dummy parameter', name: 'someparameter', trim: true
}

在我的管道工作中,我有超过 10 个字符串参数,我想将它们全部转换为小写

In my pipeline job, I have more than 10 string parameters and would like to convert them all to lowercase

推荐答案

这是一种方法:

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}"'
            }
        }
    }
}

这篇关于Jenkins 管道将所有参数转换为小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆