[OpenStack-Infra] using custom tags: include-raw-escape

Anil SB askb23 at gmail.com
Thu Feb 23 10:03:06 UTC 2017


Hi,

We use JJB version (1.6.1) and Jenkins 2.32.1 for all our jobs on ODL
infrastructure. While testing the below code, I am trying to understand
the expected behavior / differences of custom yaml tag
`!include-raw-escape` (and !include-raw). From docs in [1.] suggests
that escaping of any shell variables (${{VAR}} in the below script) is
not required when custom tags !include-raw-escape used in builder.


For instance, below code is taken from the example in docs from [1.]:

// yaml file
- job:
    name: raw-test
    builders:
      - shell:
          !include-raw-escape: include-raw001-vars.sh


// include-raw001-vars.sh
#!/bin/bash
#
# sample script to check that brackets aren't escaped
# when using the include-raw application yaml tag

VAR1="hello"
VAR2="world"
VAR3="${VAR1} ${VAR2}"

[[ -n "${VAR3}" ]] && {
    # this next section is executed as one
    echo "${VAR3}"
    exit 0
}


Once the above job is pushed into Jenkins, this gets translated to: 

#!/bin/bash
#
# sample script to check that brackets aren't escaped
# when using the include-raw application yaml tag

VAR1="hello"
VAR2="world"
VAR3="${{VAR1}} ${{VAR2}}"

[[ -n "${{VAR3}}" ]] && {{
    # this next section is executed as one
    echo "${{VAR3}}"
    exit 0
}}

Above script when run returns variable substitution errors when running
the job. Is this a expected behavior or known issue ? We also noticed
that the escaping of variables works only for some of the scripts and
not all.

Thanks,
Anil

[1.]
https://docs.openstack.org/infra/jenkins-job-builder/definition.html?highlight=job%20definition

"

The tag !include-raw-escape: treats the given string or list of strings
as filenames to be opened as one or more data blobs, which should be
escaped before being read in as string data. This allows job-templates
to use this tag to include scripts from files without needing to escape
braces in the original file.

"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.openstack.org/pipermail/openstack-infra/attachments/20170223/5413016b/attachment.pgp>


More information about the OpenStack-Infra mailing list