Pipelines: Authentication failed for 'https://x-token-auth:{access_token}@bitbucket.org/.../'

In my Bitbucket Pipelines build, I want to delete a branch using

git push origin --delete $BITBUCKET_BRANCH

But then I get the following error:

Pipelines: Authentication failed for 'https://x-token-auth:{access_token}@bitbucket.org/.../'

How can I set up my Pipelines build so that it can push to origin?

I assume one could generate an SSH key, put that inside the docker image (or inside the repo, encrypted) and add that to a Bitbucket account. However, I guess there may be an easier way you guys had in mind for this scenario.

3 answers

Hi Jens, did you ever figure this out? I'm experiencing this same thing...

Unfortunately not. I suspect one could do something with OAuth tokens, but I can't seem to find information for this exact use case.

Add this to your pipelines - git remote set-url origin https://{bitbucket_username}:{bitbucket_password}@bitbucket.org/../

If you do this you would want to make sure your bitbucket_username and bitbucket_password are in environment variables that are marked as secure in your link like so.


and then add BITBUCKET_USERNAME and BITBUCKET_PASSWORD as environment variables in your repo's or the account that own's the repo's settings under Environment variables. When setting these environment variables you can select them to be secure by checking a check box. This will prevent someone from seeing them as output in the pipeline's log.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

1,964 views 7 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you