yamlgitlab-ci

How to escape colon with following space in a GItLab CI/CD YAML value?


I have the following line in GitLab CI/CD:

  script:
    - echo "Backend image: $BACKEND_IMAGE"

But YAML interpreters treat this as an object. Then I googled this issue and tried this:

  script:
    - echo "Backend image:: $BACKEND_IMAGE"

But it still doesn't work and GitLab job fails with the following:

jobs:deploy review:script config should be a string or a nested array of strings up to 10 levels deep

If I remove colons at all it works fine. How to make a string value with colon and following space in GitLab CI/CD?


Solution

  • It should work if you surround your string with single quotes:

    script:
        - 'echo "Backend image: $BACKEND_IMAGE"'