Search code examples
herokubitbucketbitbucket-pipelines

Bitbucket pipelines configuration file error


I'm new to bitbucket pipelines and I'm following this tutorial to deploy a react app to heroku.

Deploy Reactjs app to Heroku with Multi-Environment Bitbucket CI/CD pipeline

However the file bitbucket-pipelines.yml seems to be incorrect.

Can anyone tell me what's wrong, and kindly help me to correct it?

Many thanks.

image: node:14.18.0

pipelines:
  branches:
    main:
      - step:
        name: Create artifacts
        script:
          - git archive --format=tar.gz main -o application.tar.gz
        artifacts:
          - application.tar.gz
      - step:
        name: Deploy to production
        deployment: main
        caches:
          - node
        script:
          - pipe: atlassian/heroku-deploy:1.2.1
            variables:
              HEROKU_API_KEY: $HEROKU_API_KEY
              ZIP_FILE: application.tar.gz
    develop:
      - step:
        name: Create artifacts
        script:
          - git archive --format=tar.gz main -o application.tar.gz
        artifacts:
          - application.tar.gz
      - step:
        name: Deploy to production
        deployment: main
        caches:
          - node
        script:
          - pipe: atlassian/heroku-deploy:1.2.1
            variables:
              HEROKU_API_KEY: $HEROKU_API_KEY
              ZIP_FILE: application.tar.gz
    default:

PS: A screenshot showing the errors that VSCode points out

enter image description here


Solution

  • You have a problem with the indentation and BitBucket pipelines are sensitive on that. enter image description here

    In the left is correct formatted pipeline and in the right is what you are currently using.

    Please also see bellow fully formatted pipeline

    image: node:14.18.0
    
    pipelines:
      branches:
        main:
          - step:
              name: Create artifacts
              script:
              - git archive --format=tar.gz main -o application.tar.gz
              artifacts:
              - application.tar.gz
          - step:
              name: Deploy to production
              deployment: main
              caches:
              - node
              script:
              - pipe: atlassian/heroku-deploy:1.2.1
                variables:
                  HEROKU_API_KEY: $HEROKU_API_KEY
                  ZIP_FILE: application.tar.gz
        develop:
          - step:
              name: Create artifacts
              script:
              - git archive --format=tar.gz main -o application.tar.gz
              artifacts:
              - application.tar.gz
          - step:
              name: Deploy to production
              deployment: main
              caches:
              - node
              script:
              - pipe: atlassian/heroku-deploy:1.2.1
                variables:
                  HEROKU_API_KEY: $HEROKU_API_KEY
                  ZIP_FILE: application.tar.gz