我在使用 Jenkins Job Builder YAML 文件时遇到了一些问题,该文件包含一个带有“{}”字符的属性( message-content ):
- job-template:
id: senderjob
name: '{job-prefix}{id}'
command: 'echo "executed with $PARAMETER"'
type: freestyle
properties:
- ownership:
enabled: true
owner: user1
- build-discarder:
num-to-keep: 100
parameters:
- string:
name: PARAMETER
default: 'param'
description: 'default parameter for message.'
# template settings
builders:
- shell: '{command}'
publishers:
- ci-publisher:
override-topic: VirtualTopic.abcd.message
message-type: 'Custom'
message-properties: |
release-name=$PARAMETER
PARAMETER=$PARAMETER
message-content: '{"release-name" : "1.0"}'
报告的错误是:
jenkins_jobs.errors.JenkinsJobsException: release-name parameter missing to format {release-name : 1.0}
所以看起来它正在尝试使用参数扩展“release-name”。所以我将它添加为参数:
- string:
name: release-name
default: '1.0'
description: 'default parameter for release.'
它仍然报告相同的错误。我应该在其他地方包含参数还是转义它?不过,我找不到“{}”字符的任何 YAML 转义。任何想法?