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.

https://$BITBUCKET_USERNAME:$BITBUCKET_PASSWORD@bitbucket.org/../

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 Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

706 views 0 4
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot