.gitlab-ci.yml parser bug

Summary

The pipeline report invalid yaml when the scripts key of a gitlabci stage contains a string with ": " in it (see example below)

Steps to reproduce

  • Create an empty project
  • add .gitlab-ci.yml file with following content:
stages:
- checks

test:
  stage: checks
  script:
  - echo "test: []"

With above script i have the following error:

Error: (<unknown>): found unexpected end of stream while scanning a quoted scalar at line 7 column 19

but with slightly different content, i found different errors, e.g., with - echo "test: [{foo}{bar}]" the error is:

Error: (<unknown>): did not find expected ',' or ']' while parsing a flow sequence at line 7 column 17

Remove the whitespace after test: and the bug disappear.

Workaround

If you really need the problematic whitespace, replace echo "test: []" by echo "test:"" [].

Bash will concatenate both strings, and gitlabci will be happy.