Bitbucket pipeline fail to push to heroku
Asked Answered
D

1

4

I do have a react.js app (create-react-app) I setup the file just like explained in the official docs, everything went good but the push failed with this specific line

git push https://heroku:[email protected]/$APP_NAME.git HEAD:master

The bitbucket-pipelines.yml is on the root folder:

image: node:6
clone:
  depth: full
pipelines:
  default:
    - step:
        script:
          - npm install
          - npm test
          - git push git push https://heroku:[email protected]/$APP_NAME.git HEAD:master

What I'm doing wrong? The goal here is to use the CI on bitbucket platform but also push master commits to heroku repository to automate deploys.

The error I'm getting is:

remote: !   WARNING:
remote: !   Do not authenticate with username and password using git.
remote: !   Run `heroku login` to update your credentials, then retry the git command.
remote: !   See documentation for details: https://devcenter.heroku.com/articles/git#http-git-authentication
fatal: Authentication failed for 'https://heroku
Depraved answered 13/10, 2018 at 3:7 Comment(0)
T
5

First, make sure your script does not involve git push git push https://heroku:.
It should be git push https://heroku:...

Second, as described here, make sure to use your HEROKU_API_KEY, the one returned by heroku authorizations --json (field "token")

image: node:6
clone:
  depth: full
pipelines:
  default:
    - step:
        script:
          - npm install
          - npm test
          - git push https://heroku:[email protected]/$HEROKU_APP_NAME.git HEAD:master
Thionic answered 13/10, 2018 at 6:2 Comment(7)
So in Bitbucket environment variables I should use same token?Depraved
@blvckasvp Yes, the same token as the one returned by heroku authorizations --json, in order for you to be correctly authenticated.Thionic
I believe I don't have to delete the dollar sign?Depraved
@blvckasvp If you have set the HEROKU_API_KEY variable, then $HEROKU_API_KEY will be correctly replaced by that value.Thionic
Alright it's working but got another issue, I make changes then push to bitbucket, using the pipelines it told me Updates were rejected because the remote contains work that you do: not have locally. I understand what it means it's just idk what I'm supposed to doDepraved
@blvckasvp Make sure your clone done by the pipeline is of the latest version of your remote repo: if they are new commits done on the repo, while your pipeline is trying to push its own, you would get that error message.Thionic
Let us continue this discussion in chat.Depraved

© 2022 - 2024 — McMap. All rights reserved.