Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Using ":" in bitbucket pipelines

Hello,

I'm wondering why bitbucket pipelines are parsing stings inside the script section.

image: ubuntu:18.04

pipelines:
  default:
    - step:
      script:
        -  echo "Echo from pipelines : ${MY_VAR}"

 

This is not valid because of the ":" !!

2 answers

1 accepted

3 votes
Answer accepted

Hi Hamdi,

The colon character is causing the particular line you have to be parsed as a map instead of a string. This is part of the YAML specification, which the bitbucket-pipelines.yml file follows. Specifically, a colon followed by a space will make the entire line interpreted as a map instead of a string.

There are a few ways to work around this, which will all make the line be interpreted as a string instead.

1. Remove the space after the colon

image: ubuntu:18.04

pipelines:
  default:
    - step:
      script:
        -  echo "Echo from pipelines :${MY_VAR}"

2. Escape the space after the colon

image: ubuntu:18.04

pipelines:
  default:
    - step:
      script:
        -  echo "Echo from pipelines :\ ${MY_VAR}"

3. Quote the entire command line, which will indicate the line is a string.

image: ubuntu:18.04

pipelines:
  default:
    - step:
      script:
        -  'echo "Echo from pipelines : ${MY_VAR}"'

4. Quote the colon character

image: ubuntu:18.04

pipelines:
  default:
    - step:
      script:
        -  echo "Echo from pipelines ':' ${MY_VAR}"


Thanks,

Phil

Hello Phil,

Thank you for the answer.

For me, only the option 3 works since I was using 'echo -e'.

Thanks

Like Tuomas_Tikkanen likes this

The php-codeception uses an option string like a YAML-syntax:

 ./vendor/bin/codecept run --override="paths: output: ./test-reports"

 Colons and unquoted spaces are mandatory. 
The only way I have found is:

pipelines:
  default:
    - step:
      script:
- printf './vendor/bin/codecept run --override="paths\x3a output\x3a ./test-reports"' | sh -

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,787 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you