Uploaded image for project: 'Bitbucket Cloud'
  1. Bitbucket Cloud
  2. BCLOUD-14025

Adding a colon in a string in Pipelines .yml file breaks the build

      Summary

      Adding a colon in a string in Pipelines .yml file breaks the build

      Steps to Reproduce

      1. Create a bitbucket-pipelines.yml with the following content:
      #!python
      
      pipelines:
        default:
        - step:
            script:
              - echo "Test: Colon"
      
      1. Push to trigger a build

      Expected Results

      The build runs successfully

      Actual Results

      The build fails with the following error:

      It looks that the colon in the string might be interpreted as a yaml separator?

      Notes

      For some reason, including the echo command in the string works:

      #!python
      
      pipelines:
        default:
        - step:
            script:
              - "echo Test: Colon"
      

            [BCLOUD-14025] Adding a colon in a string in Pipelines .yml file breaks the build

            Attachment 890762183-Screen%20Shot%202017-03-22%20at%2017.14.09.png has been added with description: Originally embedded in Bitbucket issue #14025 in site/master

            Theodora Boudale added a comment - Attachment 890762183-Screen%20Shot%202017-03-22%20at%2017.14.09.png has been added with description: Originally embedded in Bitbucket issue #14025 in site/master

            Romain Xie added a comment -
            - 'echo "Test: Colon"'
            

            It does not work.

            You can split the string you want to output, like:

            - 'echo "Test:"'
            - 'echo " Colon\n"'
            

            It work better for me.

            Romain Xie added a comment - - 'echo "Test: Colon" ' It does not work. You can split the string you want to output, like: - 'echo "Test:" ' - 'echo " Colon\n" ' It work better for me.

            Matt Ryall added a comment -

            Unfortunately, this is a limitation/feature of the YAML format, which actually allow inline declarations of maps. Even backslash escaping doesn't work here. Before the string even gets parsed, echo "Test: Colon" text is being correctly interpreted as a single key-value pair (key echo "Test, value Colon"), as per the YAML spec.

            The best way to avoid this is to ensure each line in your script is a YAML string. Here's one way to do it:

            pipelines:
              default:
                - step:
                    script:
                      - 'echo "Test: Colon"'
            

            We can't address this bug without deviating from the YAML spec in how we parse our configuration file, so I'm going to close this as won't fix.

            Matt Ryall added a comment - Unfortunately, this is a limitation/feature of the YAML format, which actually allow inline declarations of maps. Even backslash escaping doesn't work here. Before the string even gets parsed, echo "Test: Colon" text is being correctly interpreted as a single key-value pair (key echo "Test , value Colon" ), as per the YAML spec. The best way to avoid this is to ensure each line in your script is a YAML string. Here's one way to do it: pipelines: default : - step: script: - 'echo "Test: Colon" ' We can't address this bug without deviating from the YAML spec in how we parse our configuration file, so I'm going to close this as won't fix.

            I had the same issue but solved it by removing the space after the colon. The example above would look like this:

            pipelines:
              default:
              - step:
                  script:
                    - echo "Test:\ Colon"
            
            

            leepritchard added a comment - I had the same issue but solved it by removing the space after the colon. The example above would look like this: pipelines: default : - step: script: - echo "Test:\ Colon"

            I had, but hadn't thought to put the key value pair as a single variable. That works!
            Thanks Joshua!

            Deleted Account (Inactive) added a comment - I had, but hadn't thought to put the key value pair as a single variable. That works! Thanks Joshua!

            How are you using the Octopus API key? Have you tried using an environment variable?

            Joshua Tjhin (Inactive) added a comment - How are you using the Octopus API key? Have you tried using an environment variable?

            Is there any workaround for this? I am trying to pass an octopus api key
            Cheers
            Sam

            Deleted Account (Inactive) added a comment - Is there any workaround for this? I am trying to pass an octopus api key Cheers Sam

            Thanks for raising this. Indeed that should be valid yml.

            Joshua Tjhin (Inactive) added a comment - Thanks for raising this. Indeed that should be valid yml.

              Unassigned Unassigned
              tboudale Theodora Boudale
              Affected customers:
              0 This affects my team
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: