我有一个yml文件,我需要用Jenkins填充。
global:
name: 'my_name'
code: 'my_code'
所以,我定义了Jenkins params:
string(name: 'NAME', defaultValue: 'Nightly Valid', description: 'Nightly Valid Name')
string(name: 'CODE', defaultValue: 'NIGHTLY', description: '')
在我的Jenkins文件中,我有:
script {
def filename = "configuration.yml"
def yaml = readYaml file: filename
// General data
yaml.global.name = "${params.NAME}"
yaml.global.code = "${params.CODE}"
// ...
sh "rm $filename"
writeYaml file: filename, data: yaml
当我这样做时,我得到:
global:
name: '''my_name'''
code: '''my_code'''
我该怎么办才能拥有:
global:
name: 'my_name'
code: 'my_code'
答案 0 :(得分:1)
" $ {params.NAME}" 是 GStringImpl ,请尝试将其直接转换为字符串:"${params.NAME}".toString()