Cezar A
Cezar A

Reputation: 106

adding gitlab-ci.yml variables break pipelines

I have the following .gitlab-ci.yml configuration:

default:
    ...

stages:
    - ...

variables:
    # COLORS
    E: "\e[1;91m" # ERROR
    S: "\e[1;32m" # SUCCESS
    I: "\e[1;34m" # INFO
    R: "\033[0m" # RESET
    # Other vars
    ...

.script-before: &script-before
    - ...

.other-script: &other-script

job_1:
    before_script:
        - *script-before
    stage: ...
    only:
        - ...
    variables:
        ...
    script:
        - *other-script

The pipelines don't run with these colors variables. I have tried changing the names of the variables but still the pipelines will not trigger.

Upvotes: 0

Views: 145

Answers (1)

Patrick
Patrick

Reputation: 3250

Your pipeline doesn't run because the slash in the color isn't being escaped properly for whatever reason, so it causes the yml to not parse. While I'm not completely sure exactly why it parses that way, you can fix the issue by simply escaping the slash directly, as such:

variables:
    # COLORS
    E: "\\e[1;91m" # ERROR
    S: "\\e[1;32m" # SUCCESS
    I: "\\e[1;34m" # INFO
    R: "\\033[0m" # RESET

test:
  image: alpine:latest
  script:
    - echo -e "${E}test${R} in red font"

which will then print:

test in red font

Upvotes: 2

Related Questions