How to use .netrc file for git authentication in Bamboo?

Hello,

I am currently evaluating Bamboo on a test server I have created (Windows 7). I am using Git for the source control, and have setup the source repository for our git server. The authentication has been setup to require a username and password. To get around having to enter these details, we have been using a .netrc file with the authentication credentials. Git is able to find the .netrc/_netrc file as long as it sits in a folder under the environment variable HOME.

Is there a way to define the HOME variable for Bamboo to use when calling git? The Bamboo global variables won't help as they are referenced as ${bamboo.HOME} while git is expecting ${HOME}.

Directly entering my username and password in the git settings returns an empty response from the server, which I can reproduce from the command line in git by using the username:password@server repository connection url.

This is the output from running git on command line:

$ GIT_CURL_VERBOSE=1 git ls-remote http://username:password@****.com/git/sadmu.git
* Couldn't find host ****.com in the _netrc file; using de
faults
* About to connect() to proxy 127.0.0.1 port 3128 (#0)
*   Trying 127.0.0.1... * connected
* Connected to 127.0.0.1 (127.0.0.1) port 3128 (#0)
* 0x22947a0 is at send pipe head!
> GET http://username:password@****.com/git/sadmu.git/
info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/1.7.11.msysgit.1
Host: ****.com
Accept: */*
Proxy-Connection: Keep-Alive
Pragma: no-cache

* Empty reply from server
* Connection #0 to host 127.0.0.1 left intact
* Couldn't find host ****.com in the _netrc file; using de
faults
* Connection #0 seems to be dead!
* Expire cleared
* Closing connection #0
* About to connect() to proxy 127.0.0.1 port 3128 (#0)
*   Trying 127.0.0.1... * connected
* Connected to 127.0.0.1 (127.0.0.1) port 3128 (#0)
* 0x22947a0 is at send pipe head!
> GET http://username:password@****.com/git/sadmu.git/
info/refs HTTP/1.1
User-Agent: git/1.7.11.msysgit.1
Host: ****.com
Accept: */*
Proxy-Connection: Keep-Alive
Pragma: no-cache

* Expire cleared
* Empty reply from server
* Connection #0 to host 127.0.0.1 left intact
error: Empty reply from server while accessing http://username:password@****.com/git/sadmu.git/info/refs
fatal: HTTP request failed

1 answer

1 accepted

This widget could not be displayed.

Ok, I solved this for myself. The HOME environment variable had been set as a user variable, not system variable. Because Bamboo is run as the SYSTEM account on a Windows machine service, it was not able to see the user environment variable. Setting the HOME as a system variable made it available to Bamboo.

Suggest an answer

Log in or Sign up to answer
Community showcase
Asked yesterday in Data Center

Hi! I'm Cameron Deatsch, enterprise enthusiast and Head of Server at Atlassian. AMA!

Hey team! I'm Cameron Deatsch, Head of Server at Atlassian. At our European Summit just a few weeks ago, I spoke about the latest regarding our Server and Data center products and o...

11,248 views 2 4
View question

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