5

I have a bitbucket pipeline yaml file for a project Im working on. I had it running the pipeline fine when it was setup to run on push, but since I switched it to run on pull-request I get an invalid yml error.

I found this description of how to configure the file: https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html

In the validator, I get an error at the first step that says Expected a string but found a mapping.

When I run it via a pull-request, I get the following error:

Configuration error
There is an error in your bitbucket-pipelines.yml at [pipelines > pull-requests]. 
To be precise: This section should be a map (it is currently defined as a list).

Im not sure how to fix it, because it seems to match the example.

Below is my yml file

image: node:8.10
pipelines:
  pull-requests:
    - step: 
        name: Push repo to CodeCommit
        script:
          - echo $CodeCommitKey > ~/.ssh/codecommit_rsa.tmp
          - base64 -di ~/.ssh/codecommit_rsa.tmp > ~/.ssh/codecommit_rsa
          - chmod 400 ~/.ssh/codecommit_rsa
          - echo $CodeCommitConfig > ~/.ssh/config.tmp
          - base64 -di ~/.ssh/config.tmp > ~/.ssh/config
          - set +e
          - ssh -o StrictHostKeyChecking=no $CodeCommitHost
          - set -e
          - git remote add codecommit ssh://$CodeCommitRepo
          - git push codecommit $BITBUCKET_BRANCH
    - step:
        name: Test and Build
        caches:
          - node
        script: 
          - npm install --no-package-lock
          - npm run test
    - step:
        name: Deploy Serverless
        script:
          - npm i serverless -g
          - npm run deploy
Anthon
  • 69,918
  • 32
  • 186
  • 246
ardev
  • 653
  • 2
  • 6
  • 19

1 Answers1

6

Turns out that what I thought was just a comment, upon closer inspection was a necessary part of the file. Just make sure to indent (spaces) correctly.

image: node:8.10
pipelines:
  pull-requests:
    '**':
      - step: 
          name: Push repo to CodeCommit
          script:
            - echo $CodeCommitKey > ~/.ssh/codecommit_rsa.tmp
            - base64 -di ~/.ssh/codecommit_rsa.tmp > ~/.ssh/codecommit_rsa
            - chmod 400 ~/.ssh/codecommit_rsa
            - echo $CodeCommitConfig > ~/.ssh/config.tmp
            - base64 -di ~/.ssh/config.tmp > ~/.ssh/config
            - set +e
            - ssh -o StrictHostKeyChecking=no $CodeCommitHost
            - set -e
            - git remote add codecommit ssh://$CodeCommitRepo
            - git push codecommit $BITBUCKET_BRANCH
      - step:
          name: Test and Build
          caches:
            - node
          script: 
            - npm install --no-package-lock
            - npm run test
      - step:
          name: Deploy Serverless
          script:
            - npm i serverless -g
            - npm run deploy
ardev
  • 653
  • 2
  • 6
  • 19
  • I was also confused by this part of their [documentation](https://support.atlassian.com/bitbucket-cloud/docs/configure-bitbucket-pipelinesyml/#pull-requests). It seems like `**` should be the implied default if not written explicitly – Addison Klinke Oct 06 '21 at 15:21
  • ``` pipelines: pull-requests: development: '**': ... ``` PR for `development` seems not working as far as I know – João Carlos Brasileiro May 23 '23 at 23:24