Running Git command to SSH URL hangs on Windows agents
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Problem
When executing a Git command that connects to a SSH URL in a Script task, the task just hangs. Example:
1
git clone ssh://git@stashurl:7999/scm/proj/repo.git
Cause
When Bamboo script task runs, it's executed as a UNIX Bash script by default. Git looks for the SSH private key in %HOME%/.ssh/id_rsa
. %HOME%
by default is not set in Windows as it's defined as %USERPROFILE%
.
Hence, when the Git command is ran, it can not find the SSH private key needed.
Workaround
When using a script task (non PowerShell), set the $HOME variable before running any Git commands:
1
set HOME=%USERPROFILE%
Resolution
Run the script as a Powershell script to use Windows variable names instead of UNIX variable names.
Was this helpful?