0

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.

Janez Kuhar
  • 3,705
  • 4
  • 22
  • 45
  • 1
    practically every YAML parser I know complains about this. Curly braces in YAML stand for a flow style mapping and must be quoted if they are meant literal. I guess this YAML file is preprocessed, and those are template placeholders, so the final YAML file will be valid – tinita Feb 11 '19 at 15:13
  • **See also:** https://stackoverflow.com/questions/30905103/yaml-reusable-variables-with-case-specific-values – dreftymac Sep 30 '19 at 17:11

1 Answers1

3

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.

Anthon
  • 69,918
  • 32
  • 186
  • 246