Pipeline bitbucket-pipelines.yml file gives me an error when I use ":"
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
The YML file throws an error when I define a line in the script like this -
1
2
3
- echo "pipelines : ${MY_VAR}"
OR
- git commit -m "Next Snapshot: ${PACKAGE_VERSION}"
Cause
This issue occurs because of the way YAML syntax. When you use ":" and " $" consecutively with a space in between them.

The above screenshot shows that everything after the ":" is treated differently.
Solution
There are multiple ways to deal with solution:
Remove the space after the colon
1 2 3 4 5 6 7
image: ubuntu:18.04 pipelines: default: - step: script: - echo "Echo from pipelines :${MY_VAR}"
Escape the space after the colon
1 2 3 4 5 6 7
image: ubuntu:18.04 pipelines: default: - step: script: - echo "Echo from pipelines :\ ${MY_VAR}"
Quote the entire command line, which will indicate the line is a string.
1 2 3 4 5 6 7
image: ubuntu:18.04 pipelines: default: - step: script: - 'echo "Echo from pipelines : ${MY_VAR}"'
Quote the colon character
1 2 3 4 5 6 7
image: ubuntu:18.04 pipelines: default: - step: script: - echo "Echo from pipelines ':' ${MY_VAR}"
Updated on April 24, 2025
Was this helpful?
Still need help?
The Atlassian Community is here for you.