2


I'm having some issues with a Jenkins Job Builder YAML file which contains an attribute (message-content) with "{}" characters in it:

- 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"}'

The error reported is:

jenkins_jobs.errors.JenkinsJobsException: release-name  parameter missing to format {release-name : 1.0}

So it looks like it's trying to expand "release-name" with a parameter. So I have added it as parameter:

- string:
  name: release-name
  default: '1.0'
  description: 'default parameter for release.'

It still reports the same error. Should I include the parameter somewhere else or escape it ? I couldn't find any YAML escape for "{}" characters though. Any idea?

Francesco Marchioni
  • 4,091
  • 1
  • 25
  • 40

1 Answers1

0

You should add the following to the configuration file

[job_builder]
allow_empty_variables = True

Link: https://jenkins-job-builder.readthedocs.io/en/latest/definition.html#job-template-1

Luca Kiebel
  • 9,790
  • 7
  • 29
  • 44