Bamboo failing to git push changes

Julie Cochrane September 23, 2013

Hi,

We upgraded from Bamboo 4.3.3 to Bamboo 5.1.1 and since doing so we are unable to release anything through bamboo.

We run our own custom scripts which, for the given project, merge a staging branch into master, release then push the release tag back upto GitHub. This worked fine up until the upgrade, now we get the following output:

remote: error: refusing to update checked out branch: refs/heads/master[K
remote: error: By default, updating the current branch in a non-bare repository[K
remote: error: is denied, because it will make the index and work tree inconsistent[K
remote: error: with what you pushed, and will require 'git reset --hard' to match[K
remote: error: the work tree to HEAD.[K
remote: error: [K
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to[K
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into[K
remote: error: its current branch; however, this is not recommended unless you[K
remote: error: arranged to update its work tree to match what you pushed in some[K
remote: error: other way.[K
remote: error: [K
remote: error: To squelch this message and still keep the default behaviour, set[K
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.[K
To file:///opt/bamboo/home/xml-data/build-dir/_git-repositories-cache/6649fa8e22d03ac8715bfa68bc677833d344f89a
* [new tag]         ****-20 -> ****-20
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'file:///opt/bamboo/home/xml-data/build-dir/_git-repositories-cache/6649fa8e22d03ac8715bfa68bc677833d344f89a'
	
Fatal error: local() encountered an error (return code 1) while executing 'git push origin master --tags'

I've tried clearing the _git-repositories-cache to no avail. I realise this could be a problem particular to us as we use custom scripts, but was wondering whether anyone had encountered anything similar?

Any suggestions welcome.

Thanks.

7 answers

0 votes
Scott Moorhouse
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 9, 2018

Bamboo can be set to cache git repos on remote agents. If it does that, origin is set to the cached location (in my case a file:/// url) instead of the remote you might expect.

$ git remote -v

origin    file:///opt/bamboo-agent-home/xml-data/build-dir/_git-repositories-cache/6a2fb72d82c212107cd1308fd3d2679297480385 (fetch)
origin    file:///opt/bamboo-agent-home/xml-data/build-dir/_git-repositories-cache/6a2fb72d82c212107cd1308fd3d2679297480385 (push)

You could push the commit to a new remote...

$ git remote add server ${bamboo_planRepository_repositoryUrl}
$ git push server master

 ... with the understanding that this will make the cache out of sync with the remote authority.

0 votes
Matt Frankenfield
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 6, 2016

Any update on this, I have the exact same issue.

0 votes
Bernd_Schulte
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 16, 2016

I also encounter this horrible situation ...

Instead of "regular" git repositories, do I have no chance to handle the stash repository (on the origin/server) with git command line tools ?!

0 votes
Martin Jones
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 7, 2016

I came across this having encountered a similar problem when trying to push to a Stash repository after building in Bamboo.  
Not sure if it'll be the same solution, but the problem I had was down to Bamboo clone'ing the remote Stash repo, then setting the "remote" repository to the locally checked out one (using "git remote set-url ...).  This wasn't a step added by me, this was one of the built-in steps Bamboo took as part of the checkout from git.


The issue was resolved for me (allowing me to push back to Stash) by resetting the remote repo to Stash prior to attempting a git push origin...

GeraldW
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 6, 2018

Thank you very much for posting this information. I don't know why Atlassian support could not have answered this. 

Like Martin Jones likes this
Jess Chadwick
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 8, 2019

by resetting the remote repo to Stash prior to attempting a git push origin

Can you elaborate?  Can you provide a screenshot or command snippet of what, exactly, you did?

Martin Jones
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 25, 2020

I'm probably too late in responding to be helpful...but from what I recall it was just a case of using the git remote set-url command, with the URL of the original remote stash repo rather than the local one the Bamboo checkout had changed it to.

Hence like this answer explains:
https://stackoverflow.com/a/2432799

Sorry I can't be more help, it was a while ago and I've since changed jobs so can't double check the details.

0 votes
Nils Kuhn
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 15, 2016

I have the same problem.

Can't believe that nobody fixed this since September 2013.

Is there another way to push to a git repository than from a custom script?

0 votes
wsmckenz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 27, 2014

Did you ever find a solution to this? I have the same problem.

0 votes
Xavier Arques
Contributor
December 4, 2013

Peter,

I've got the same error with bamboo 5.2.2. Did you fix it ?

Regards

Xavier

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events