groovy - Jenkins 管道将所有参数转换为小写
问题描述
如何将 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}"'
}
}
}
}
推荐阅读
- asp.net - 这个 NHibernate 5 查询不支持什么?
- javascript - 如何修复丢失的脚本:服务?
- c# - “链接表管理器”功能以编程方式使用 c#
- laravel - 如何在 Laravel 验证中添加错误消息?
- swift - 如何获取放置在表格视图单元格上的标签的值
- java - 在java中使用aws sdk版本2的合理好方法,请求apigateway
- python - 我正在尝试为 SQL 加载 python 扩展,但是当我尝试时我得到了这个
- mysql - 如何从mysql中的表中跳过行
- c++ - C++ 模板 - 在类外实现
- tensorflow - 使用 TPUClusterResolver 时为 TPU 转储 HLO IR