Skip to content

Latest commit

 

History

History
77 lines (49 loc) · 1.85 KB

File metadata and controls

77 lines (49 loc) · 1.85 KB

Bitbucket

A legacy Git repo hosting provider with the worst CI/CD of the major 4 Git hosting providers.

SSH Keys

https://bitbucket.org/account/settings/ssh-keys/

App Passwords

Deprecated in favour of API Tokens.

https://bitbucket.org/account/settings/app-passwords/

API Tokens

Create an API token here:

https://id.atlassian.com/manage-profile/security/api-tokens

and then copy, save it and export it:

export BITBUCKET_TOKEN=...

Git Clone over HTTPS using App Password or API Token

Cloning with HTTPS then becomes:

git clone "https://$BITBUCKET_TOKEN@bitbucket.org/$ORG/$REPO.git"

or better using a credential helper...

Credential Helper

Taken from my .gitconfig:

[credential "https://bitbucket.org"]
    helper = "!f() { sleep 1; echo \"password=${BITBUCKET_TOKEN}\"; }; f"
git clone "https://bitbucket.org/$ORG/$REPO.git"

If you get a 401 or 403 authentication or authorization error, you can check Git debug output by setting:

export GIT_CURL_VERBOSE=1

You may need to put your username in the Bitbucket URL if using App Passwords in order to get past the 403 error:

https://harisekhon@bitbucket.org/...

in order to get this to work as the behaviour even when trying the credential helper with the username seems to not work:

[credential "https://bitbucket.org"]
    helper = "!f() { sleep 1; echo \"username=${BITBUCKET_USER}\"; echo \"password=${BITBUCKET_TOKEN}\"; }; f"