Git and Bamboo Remote Agent?

Hi,

 

I have Bamboo running on a windows server as SYSTEM user. 

I have one remote agent, which is also ran as SYSTEM user. 

The git clone command fails. Do I have to set up ssh keys on each remote agent? If so doesn't that mean I have to run Bamboo and Bamboo remote agents as a specific user and not a SYSTEM user?

Any advice on the best way to set up remote agents and access to repositories in the most generic way would be appreciated. The Bamboo server will be a centrally maintained instance where we want to easily add remote agents as the number of teams increase.  

3 answers

I always had problems getting ssh running as SYSTEM.

It is much easier if you configure the agent service to run as a specific "auto-build" user.
Then you can login yourself and prepare the environment (keys, knownhosts etc.).
Also you then can configure permissions on Bamboo (or Stash if you use that) for that user if thats also needed.

I am running Bamboo server on linux now but also tested it on Windows some tme ago. For Windows i think i also used the same user as the service account.

And yes, you have to configure ssh keys on the server and on each agent. Especially if you use submodules. If you dont use them you might get away with just configuring shared credentials in Bamboo.

0 votes
Daniel Wester Community Champion Nov 05, 2014

You only have to configure the ssh keys on the server and the agent if you're shelling out to command line as part of your build (and even then you can pass in the ssh tunnel to use so you don't need to do that).

 

If you're using the Checkout from Source task you just have to upload the ssh key into the task's configuration. 

What's the error you're getting? It might be more of a system issue.

That is incorrect if Use Submodules option is enabled.

Daniel Wester Community Champion Nov 05, 2014

That might be true (and I don't know about submodules usage in Bamboo since I haven't had to use them in a while) but he didn't ask about submodules but rather "to set up remote agents and access to repositories in the most generic way ". But if you want to use submodules with ssh keys - there's a feature at https://jira.atlassian.com/browse/BAM-11369 it has how Atlassian does it (more specifically https://jira.atlassian.com/browse/BAM-11369?focusedCommentId=552009&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-552009 )

I think thats a genreic problem of the git submodule command. Bamboo still uses the configured git.exe command executable for the agent for any submodule handling (instead of a java implementation). As long as the "git submodule" shell command is used, it will have the problem i mentioned. This command does not use Bamboo shared credentials and i dont know a way how Bamboo could pass these credentials unless they do something like copying the private key to $HOME/.ssh/id_rsa (or in Windows the users profile home directory) before starting the first git command.

Daniel Wester Community Champion Nov 05, 2014

Bamboo used to use jgit but moved away from it (it wasn't implementing features fast enough). The above scripts sets the GIT_SSH environment variable to set the key ( https://bitbucket.org/atlassian/atlassian-connect/src/021e798027e18e87d4175dca1ecef0f4007c6b91/bin/copy-key.sh?at=develop ) I'm guessing that the AC team passes that in from a script task or similar.

It still needs a script (which creates the id_rsa file), would be really cool if everything would be inline

Hi Guys, First of all. Thank you very much for the responses :-) The error we are getting is: java.lang.RuntimeException: com.atlassian.bamboo.plugins.stash.repository.StashRepositoryException: com.atlassian.bamboo.repository.RepositoryException: Cannot fetch branch '(unresolved) master' from 'ssh://git@ccd1is0271.ccd1.root4.net:7999/bam/somefiles.git' to source directory 'F:\opt\Bamboo_home\xml-data\build-dir\TOOL-TES-JOB1'. com.atlassian.bamboo.plugins.git.GitCommandException: command 'C:\Program Files (x86)\Git\cmd\git.exe' ls-remote ssh://98e76c11-655d-4501-81d8-c6c74e2bcab0@127.0.0.1:51421/bam/somefiles.git failed with code 128. Working directory was [F:\opt\Bamboo_home\xml-data\build-dir\TOOL-TES-JOB1]., stderr: [error: cannot spawn C:\WINDOWS\system32\config\systemprofile\AppData\Local\Temp\bamboo-ssh.41538fd5.bat: No such file or directory, fatal: unable to fork]

This will be a centrally administered server. As build times and queue's increase we want to be able to add more slaves, pretty much the same capabilities, as needed. So if I have understood, is it correct to say? The Bamboo Server and all Remote agents should be ran as the same dedicated user and not as SYSTEM user on windows. This users SSH key should be installed in the .ssh folder on the remote agents. The ssh key should be added to projects in stash.

I am wondering if the real issue is this:

error: cannot spawn C:\WINDOWS\system32\config\systemprofile\AppData\Local\Temp\bamboo-ssh.41538fd5.bat: No such file or directory, fatal: unable to fork

If the agent, which is running as SYSTEM user does not have access to system32\config\systemprofile\AppData\Local\Temp to create the .bat file? 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

427 views 6 9
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