You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
Hi
I am trying to write a Bitbucket Pipelines script that automatically add a git tags to on the master branch
image: maven:3.3.3
pipelines:
default:
- step:
script:
- mvn clean install
branches:
master:
- step:
script:
- mvn clean install
- git tag THE_VERSION
- git push
Pipelines gives me an error saying it is unable to authenticate to when it attempts the push
remote: Invalid username or password. If you log in via a third party service you must ensure you have an account password set in your account profile.
fatal: Authentication failed for 'https://x-token-auth:{access_token}@bitbucket.org/deepskyblue/xero-client.git/'
Anyone have any ideas how I get this working?
thanks
Richard
Mine script is below. To use it, you need to
- step: &tag
name: Tag version
image: atlassian/default-image:2
script:
- git remote set-url origin ${BITBUCKET_GIT_SSH_ORIGIN}
- dt=$(date '+%Y-%m-%d_%H%M');
- git tag $dt ${BITBUCKET_COMMIT}
- git push origin --tags
Here you have full documentation of pipeline-git authorization: https://confluence.atlassian.com/bitbucket/push-back-to-your-repository-962352710.html
Part of my build process I also push back to the same repo. Using an oauth token I run this command to set my remote with auth:
git remote set-url origin https://x-token-auth:${BITBUCKET_TOKEN}@bitbucket.org/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}.git
The BITBUCKET_TOKEN env variable was something I generate in my scripts because they expire, so I need to generate a new one each build.
In my case, I also needed to setup the user config:
git config --global user.email "builder@example.com"
git config --global user.name "Build"
Then I could do whatever git operations I needed to do.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Alex
Are you able to share the script you use to generate BITBUCKET_TOKEN? I am confused how you do this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was having a similar issue "fatal: could not read Username for 'http://bitbucket.org': No such device or address".
The Bitbucket docs linked above suggest that this should just work without having to switch to ssh. On further investigation, it seems that I was getting the error because I was using my own Docker image in the step. I refactored this bit of the pipeline into its own step and used one of the stock Bitbucket agents (in my case I added image: python:3.7.2). This then worked fine.
I know it's a tiny bit slower and won't suit all cases, but worked well for me and is a bit simpler than messing with SSH keys.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi everyone, We are looking to learn more about development teams’ workflows and pain points, especially around DevOps, integrations, administration, scale, security, and the related challeng...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.