我在同一个视图中有一堆作业,它们使用相同的声明性管道结构,除了以下部分:
parameters {
string(name: 'total_try_count', defaultValue: '1', description: '總的嘗試次數')
choice(name: 'intermediate_dir', choices: '/var/lib/jenkins-slave/', description: '在放入 NAS 前保存視頻和字幕的目錄')
booleanParam(name: 'unplanned_download', defaultValue: false, description: '臨時起意的下載?')
...
...
choice(name: 're_pattern', choices: '', description: '正則表達式待匹配模式')
booleanParam(name: 're_remove_spaces', defaultValue: true, description: '刪除文件名中的空格?')
string(name: 're_new_pattern_prefix', defaultValue: '', description: '正則表達式新模式前綴')
}是否可以将参数存储在文本文件中,然后像C/C++中的#include指令那样将它们包含在管道中
发布于 2021-11-01 05:11:50
我的Jenkinsfile文件:
#!/usr/bin/env groovy
import hudson.model.*
import hudson.EnvVars
node('whatever') {
checkout scm
def options = load 'script.groovy'
properties([parameters(options.params())])
println "${params.TEST_PARAM}"
}我的外部groovy文件script.groovy:
def params() {
[
string(defaultValue: 'default', description: '', name: 'TEST_PARAM', trim: true)
]
}
return this输出:
[Pipeline] load
[Pipeline] { (script.groovy)
[Pipeline] }
[Pipeline] // load
[Pipeline] properties
[Pipeline] echo
default
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESShttps://stackoverflow.com/questions/69785421
复制相似问题