Running Git command to SSH URL hangs on Windows agents
Problem
When executing a Git command that connects to a SSH URL in a Script task, the task just hangs. Example:
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:
set HOME=%USERPROFILE%
Resolution
Run the script as a Powershell script to use Windows variable names instead of UNIX variable names.