是否可以通过在实际脚本中列出参数而不是在作业配置中来在 Jenkins 中创建参数化脚本化管道 [英] Is it possible to make a parameterized scripted pipeline in Jenkins by listing the parameters in actual script, not in job config
本文介绍了是否可以通过在实际脚本中列出参数而不是在作业配置中来在 Jenkins 中创建参数化脚本化管道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在
但是,是否可以这样做:
节点{参数([字符串(名称:'DEPLOY_ENV',默认值:'TESTING')])}
解决方案
通过实验找到了解决方案,分享一下:
节点{特性([参数([字符串(默认值:'/data',名称:'目录'),字符串(默认值:'Dev',名称:'DEPLOY_ENV')])])……}
In a declarative pipeline, I can specify the parameter that the pipeline expects right in the pipeline script like so:
pipeline {
parameters([
string(name: 'DEPLOY_ENV', defaultValue: 'TESTING' )
])
}
is it possible do to in a scripted pipline? I know I can do this :
BUT, IS IT POSSIBLE TO DO THIS:
node{
parameters([
string(name: 'DEPLOY_ENV', defaultValue: 'TESTING' )
])
}
解决方案
I found a solution by experimentation so want to share it:
node {
properties(
[
parameters(
[string(defaultValue: '/data', name: 'Directory'),
string(defaultValue: 'Dev', name: 'DEPLOY_ENV')]
)
]
)
....
}
这篇关于是否可以通过在实际脚本中列出参数而不是在作业配置中来在 Jenkins 中创建参数化脚本化管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文