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 18Common 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
- Wrap the script entry in single or double quotes.
- Re-run CI Lint to confirm the file now parses.
- 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"
makeHow 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
GitLab CI "yaml invalid: did not find expected key" in CIFix GitLab "Invalid configuration format ... did not find expected key" in CI - the .gitlab-ci.yml has a YAML…
GitLab CI "jobs config should contain at least one visible job" in CIFix GitLab "jobs config should contain at least one visible job" in CI - every job in .gitlab-ci.yml is hidde…
GitLab CI "rules:if ... unknown variable" in CIFix GitLab "rules:if ... unknown variable" / invalid expression in CI - a rules expression references a varia…