Janez Kuhar
Janez Kuhar

Reputation: 4266

Curly braces in a YAML file

I've found the following .travis.yml template.

I've noticed this:

    repo: {GITHUB_USER}/{PROJECT_NAME}

Is this a special .yml variable syntax I'm not familiar with? Where can I set these values (GITHUB_USER, PROJECT_NAME)?


I know I can use environment variables, like so:

    repo: $GITHUB_USER/$PROJECT_NAME

but this syntax looks different.

Upvotes: 0

Views: 10214

Answers (1)

Anthon
Anthon

Reputation: 76614

That is not a valid YAML file. After the first } the YAML parser will expect a block style continuation. This means either a key that aligns with repo or outdenting. Instead it finds a / and any YAML parser should throw an error on that.

This looks like a template for a YAML file, e.g. using something like the following in Python after loading the contents of the file in string templ:

templ.format(**dict(GITHUB_USER="Janez", PROJECT_NAME="test"))

On the other hand the recommended extension for YAML files has been .yaml for many more years than Travis exists, so maybe that is why they used the .yml extension.

Upvotes: 3

Related Questions