Checkout of Git repository with submodules failed in Bamboo

Still need help?

The Atlassian Community is here for you.

Ask the community

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:

Enable the option at Repository Configuration >> Advanced Options >> SSH key applies to submodules 

Workaround

Submodules accessed via SSH

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.

  1. Create _netrc file 

    machine <hostname>
    login <login>
    password <password>

    ie.

    machine bitbucket.org
    login kbrazulewicz
    password ******
  2. Copy _netrc to the home directory of account used by Bamboo
    1. C:\WINDOWS\system32\config\systemprofile for instances running as system service
    2. user's home directory for instances run from console
  3. Repeat the copy for all remote agents that are supposed to checkout this repository
  4. If Bamboo is run as service (using Local System Account) you should make sure that HOME environment variable is set
    1. Go to Administration / System information, scroll down to section Environment Variables and check if HOME variable is defined
    2. If not, create a no-repository plan with a script task that would run

      setx HOME C:\WINDOWS\system32\config\systemprofile
    3. Run this plan on local agent
    4. Run this plan on all remote agents that are supposed to checkout this repository
    5. Reboot Bamboo server (it is not enough to restart service)
    6. Reboot all remote agents that are supposed to checkout this repository
    7. Go to Administration / System information, scroll down to section Environment Variables and verify if HOME variable is defined

Now Bamboo should be able to successfully checkout repository and initialize submodules

Last modified on Sep 22, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.