是否可以通过在实际脚本中而不是作业配置中列出参数来在Jenkins中创建参数化脚本管道 [英] Is it possible to make a parameterized scripted pipeline in Jenkins by listing the parameters in actual script, not in job config
本文介绍了是否可以通过在实际脚本中而不是作业配置中列出参数来在Jenkins中创建参数化脚本管道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在声明性管道中,我可以指定参数管道期望在管道脚本中像这样:
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屋!
查看全文