runatlantis / atlantis

Terraform Pull Request Automation
https://www.runatlantis.io
Other
7.73k stars 1.05k forks source link

Issue with bitbucket authentication #2437

Open danmcnulty opened 2 years ago

danmcnulty commented 2 years ago

Hi, I'm trying to setup Atlantis and integrate it with Bitbucket.... so far I created a webhook in our Bitbucket repo to call out to our atlantis server /events URL and set it to trigger on pullrequest:created and pullrequest:updated - and when I update a PR I see successful (HTTP 200) requests logged.

However, in the Atlantis logs I see errors like this:

{
    "level": "error",
    "ts": "2022-08-10T16:21:58.472Z",
    "caller": "events/instrumented_project_command_builder.go:48",
    "msg": "Error building auto plan commands: making request \"GET https://api.bitbucket.org/2.0/repositories/companyname/reponame/pullrequests/66/diffstat\" unexpected status code: 401, body: Bitbucket Cloud recently stopped supporting account passwords for API authentication.\nSee our community post for more details: https://atlassian.community/t5/x/x/ba-p/1948231\nApp passwords are recommended for most use cases and can be created in your Personal settings:\nhttps://bitbucket.org/account/settings/app-passwords/\nFor more details on API authentication methods see our documentation:\nhttps://developer.atlassian.com/cloud/bitbucket/rest/intro/#authentication\n",
    "json": {},
    "stacktrace": "github.com/runatlantis/atlantis/server/events.(*InstrumentedProjectCommandBuilder).BuildAutoplanCommands\n\tgithub.com/runatlantis/atlantis/server/events/instrumented_project_command_builder.go:48\ngithub.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).runAutoplan\n\tgithub.com/runatlantis/atlantis/server/events/plan_command_runner.go:73\ngithub.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).Run\n\tgithub.com/runatlantis/atlantis/server/events/plan_command_runner.go:222\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunAutoplanCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:173"
}

This is despite the fact that I am using an app password to authenticate and the same credentials work fine using curl eg:

curl -X GET -u "username:app-password" "https://api.bitbucket.org/2.0/repositories/companyname/reponame/pullrequests/66"

Any help would be appreciated. Thanks

zer0beat commented 2 years ago

Hi! I get the same error. To solve it, you must use your username and not the email as a Bitbucket user.

To find your username:

  1. Select Avatar > Personal settings.
  2. Under Bitbucket profile settings > Username

I hope this helps you!