Checkout of Git repository with submodules failed in Bamboo
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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
Summary
Checkout for repositories with submodules fails.
Diagnosis
The following appears in the atlassian-bamboo.log
:
'C:\Program Files (x86)\Git\bin\git.exe' submodule update --init --recursive
Cloning into '<submodule-path>'...
fatal: Authentication failed
Clone of '<repository-url>' into submodule path '<submodule-path>' failed
Cause
Bamboo support for submodules is limited in older versions. In particular, Bamboo doesn't provide credentials for submodule operations and the credentials must be available to Git via the environment on the agent.
Solution
Submodules accessed via SSH
Upgrade to Bamboo 8.1.1 which provides submodule authentication support:
- BAM-11369 - Getting issue details... STATUS
Enable the option at Repository Configuration >> Advanced Options >> SSH key applies to submodules
Workaround
Submodules accessed via SSH
- Configure passwordless SSH keys for the account used by Bamboo: Bitbucket Server and Cloud Repositories With Git Submodules
Submodules accessed via HTTP/HTTPS
Windows
Option 1: Recommended
Use Git Credential Manager. Make sure GCM_INTERACTIVE is set to Never.
Option 2:
This workaround involves storing credentials in plaintext in a file and may not be suitable for all environments depending on security requirements.
Create
_netrc
filemachine <hostname> login <login> password <password>
ie.
machine bitbucket.org login kbrazulewicz password ******
- Copy
_netrc
to the home directory of account used by BambooC:\WINDOWS\system32\config\systemprofile
for instances running as system service- user's home directory for instances run from console
- Repeat the copy for all remote agents that are supposed to checkout this repository
- If Bamboo is run as service (using Local System Account) you should make sure that
HOME
environment variable is set- Go to Administration / System information, scroll down to section Environment Variables and check if
HOME
variable is defined If not, create a no-repository plan with a script task that would run
setx HOME C:\WINDOWS\system32\config\systemprofile
- Run this plan on local agent
- Run this plan on all remote agents that are supposed to checkout this repository
- Reboot Bamboo server (it is not enough to restart service)
- Reboot all remote agents that are supposed to checkout this repository
- Go to Administration / System information, scroll down to section Environment Variables and verify if
HOME
variable is defined
- Go to Administration / System information, scroll down to section Environment Variables and check if
Now Bamboo should be able to successfully checkout repository and initialize submodules