Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do I connect to bitbucket using git commands ?

I do have set of commands which creates a tag and store it to bitbucket . The commands are working fine in local , git bash , but in Bamboo it is redirecting to other location , not to bitbucket 

git remote add central https://n036206:${bamboo_bitbucket_password}@bitbucket.devapps.westernpower.com.au/scm/mrc_poc/erpldapuser_test.git
git config --global user.email Upasana.Ghosh@westernpower.com.au
git config --global user.name n036206
git show-ref --tags
git describe --tags --abbrev=0
git init
git checkout develop
git checkout master
git checkout -b release/erpldapuser-test-1.0.3
git merge --no-ff release/erpldapuser-test-1.0.3
git tag -a erpldapuser-test-1.0.3 -m "my version"
git checkout develop
git merge --no-ff release/erpldapuser-test-1.0.3 -m "my version"
git push --tags
git push origin develop
git push origin master

The results of git push --tags should store to To https://bitbucket.devapps.westernpower.com.au/scm/mrc_poc/erpldapuser_test.git this location which is happening in locally fine but not through bamboo . In bamboo it is redirecting to some other location . Screenshot attached 

I have added these steps initially to the bitbucket url but not helping out . 

any help or suggestion ??ex1.PNG

1 answer

1 accepted

2 votes
Answer accepted

Hi @Upasana Ghosh !

Probably Bamboo is pushing changes to a cached remote instead of your original remote.

According to https://jira.atlassian.com/browse/BAM-11930, if you are using Bamboo > 7.1.0, you could try to unset "use agent cache". In case you don't, there are some workarounds (for instance configure a Remote Agent in the main Bamboo server, instead of using the Local Agent).

In case none of this is applicable, you could set the remote git repo before the push command.

Hope this helps!

Cris

@Cristiano Mariano  Thank you for your suggestion . 

Bamboo Version is : 6.10 

And I have set the remote git repo at the beginning itself 

git remote add central https://n036206:${bamboo_bitbucket_password}@bitbucket.devapps.westernpower.com.au/scm/mrc_poc/erpldapuser_test.git

 

But this is not working ultimately . 

Any other suggestion or advise ? 

Hi @Upasana Ghosh !

I have seen you add the remote with the name "central", but in git push you send it to "origin". Would you try to change the 3 lines in the end?

git push central --tags
git push central develop
git push central master

@Cristiano Mariano  Hi 

It seems , bamboo not able to execute this line : 

git remote add central https://n036206:${bamboo_bitbucket_password}@bitbucket.devapps.westernpower.com.au/scm/mrc_poc/erpldapuser_test.git 

 

I have tried adding with central too , but no luck . 

Attached two screenshots . 

Any idea how to mention bitbucket repository through git commands in bamboo? 

ex3.PNGex2.PNG

@Upasana Ghosh 

The "URL using bad/illegal format..." error indicates that your password variable is not being evaluated or that it contains a char that would break the URL (a slash for example).

Would you test the password variable in order to check it is being correctly evaluated? Another try would be to surround the URL with double quotes.

@Cristiano Mariano  

 

git remote add central "https://n036206:${bamboo_bitbucket_password}@bitbucket.devapps.westernpower.com.au/scm/mrc_poc/erpldapuser_test.git/"
git config --global user.email Upasana.Ghosh@westernpower.com.au
git config --global user.name n036206
git show-ref --tags
git describe --tags --abbrev=0
git init
git checkout develop
git checkout master
git checkout -b release/erpldapuser-test-1.0.3
git merge --no-ff release/erpldapuser-test-1.0.3
git tag -a erpldapuser-test-1.0.3 -m "my version"
git checkout develop
git merge --no-ff release/erpldapuser-test-1.0.3 -m "my version"
git push central --tags
git push central develop
git push central master

 

The password works fine locally in git bash ..as per your suggestion , added double quotes . Rechecked the password in variable section . The same error . 

and the password contains a-z character and number . No special char . 

ex4.PNG

This is very odd.

Would you please try to "echo" the password variable in Bamboo?

In case it works, please, do NOT post a print screen here :-)

@Cristiano Mariano no it does not give any result of echo ${bamboo_bitbucket_password}   :(

Hi @Upasana Ghosh !

Just to confirm: are you using Inline Script or File Script tasks?

If you are using Inline, the variable shoud be ${bamboo.<variable name>}

If you are using Script, the variable shoud be $bamboo_<variable name replacing . by _> (without curly braces).

Would you change that and give it a try?

@Cristiano Mariano I am using inline method : 

git remote add central "https://n036206:${bamboo.bitbucketpassword}@bitbucket.devapps.westernpower.com.au/scm/mrc_poc/erpldapuser_test.git/"

error 30-Jul-2021 03:57:58 /home/bamboo/bamboo-agent-home/temp/ELLIPSE-EST-JOB1-112-ScriptBuildTask-1038264493539552658.sh: 1: Bad substitution
simple 30-Jul-2021 03:57:58 Failing task since return code of [/home/bamboo/bamboo-agent-home/temp/ELLIPSE-EST-JOB1-112-ScriptBuildTask-1038264493539552658.sh] was 2 while expected 0

But no luck :( 

I have recreated a build in my Bamboo instance, using exactly the same command line as you and it worked. This is very strange.

Sorry if I am being too obvious, but you created the variable "bitbucketpassword" in the Variables tab of your plan configuration, right? :-)

@Cristiano Mariano  

ex5.PNG

Yes i used that only. 

Not sure where went wrong actually . 

still the same error of 

fatal: unable to access 'https://bitbucket.devapps.westernpower.com.au/scm/mrc_poc/erpldapuser_test.git/': URL using bad/illegal format or missing URL

@Cristiano Mariano  does it require user admin access of bitbucket ?? 

cause for my user I do have only read and write access . 

In fact, no special permission would be required.

Do you use LinkedIn? If you want, you can send me an invitation (I did not find you) and we can schedule a meeting and share screens. I got really curious about your scenario.

@Cristiano Mariano  I too tried to find you but did not get .. can you send me request ? 

here is my linkdin id : Upasana Ghosh | LinkedIn 

 

 

Hi @Upasana Ghosh !

As we just talked, the issue was a special char in URL.

Thank you very much for your time!

Like # people like this

@Cristiano Mariano   yes it worked . thank you for your time and resolve the issue . It was really grateful . Nice to came across a person like you :) 

Like Cristiano Mariano likes this

Heh, read this drama just now - yeah, my first thought was "strange characters in expanded variables, or some special hidden character in a URL" (Both of which I've experienced, and both of which were frustrating until I realized what the problem was).

Like Cristiano Mariano likes this

Suggest an answer

Log in or Sign up to
This widget could not be displayed.
TAGS
Community showcase
Published in Bamboo

Bamboo Data Center is here!

G’day Bamboo customers, The wait is over! Bamboo Data Center edition you have been asking for is finally here! This self-managed enterprise offering of Bamboo has the resilience, reliability, and s...

435 views 1 17
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you