Skip to content
Latchkey

GitLab CI "mapping values are not allowed here" in CI

A colon followed by a space inside an unquoted scalar makes YAML try to read a key/value pair where a plain string was expected. The fix is almost always to quote the offending line.

What this error means

CI Lint or the pipeline rejects the file with "mapping values are not allowed in this context" at a line that contains a colon, often inside a script entry or an echo.

Pipeline Editor / CI lint
Invalid configuration format
(<unknown>): mapping values are not allowed in this context at line 5 column 18

Common causes

An unquoted colon inside a script line

A command like echo Build: done contains : , which YAML parses as a mapping separator instead of literal text.

An unquoted URL or time value

Values such as https://host or 12:00 contain colons; left unquoted in some positions they confuse the parser.

How to fix it

Quote the line containing the colon

  1. Wrap the script entry in single or double quotes.
  2. Re-run CI Lint to confirm the file now parses.
  3. Push and verify the pipeline creates.
.gitlab-ci.yml
script:
  - 'echo "Build: done"'

Use a block scalar for multi-line commands

A literal block avoids quoting headaches when commands contain colons.

.gitlab-ci.yml
script:
  - |
    echo "Stage: build"
    make

How to prevent it

  • Quote any script line that contains ": ".
  • Prefer block scalars for commands with special characters.
  • Run CI Lint before pushing config changes.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →