Bamboo Source code checkout task fails with "no submodule mapping found in .gitmodules for path 'script'"
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
When the build tries to run the Source code checkout task it fails with an error similar to this:
error Caused by: com.atlassian.bamboo.repository.RepositoryException: Checkout to revision 7c3c7b5a26c35ba3752c043b25c7d7e27f3c16b82 has failed.command [/usr/bin/git submodule update --init --recursive] failed with code 128. Working directory was [/root/bamboo-agent-home/xml-data/build-dir/PROJECT-PLAN-JOB1]., stderr:
error fatal: no submodule mapping found in .gitmodules for path 'script'
Environment
The issue is seen on Bamboo 7.1.2 but is applicable to any supported version.
Diagnosis
The problem is seen while trying to run a build that has a Source code checkout task. The build is going to fail and in the logs you will see the following error:
error Caused by: com.atlassian.bamboo.repository.RepositoryException: Checkout to revision 7c3c7b5a26c35ba3752c043b25c7d7e27f3c16b82 has failed.command [/usr/bin/git submodule update --init --recursive] failed with code 128. Working directory was [/root/bamboo-agent-home/xml-data/build-dir/PROJECT-PLAN-JOB1]., stderr:
error fatal: no submodule mapping found in .gitmodules for path 'script'
Cause
This error message suggests that the Git submodule update command failed while trying to checkout a specific revision ('7c3c7b5a26c35ba3752c043b25c7d7e27f3c16b82') in the repository. The specific error is related to the submodule 'script'.
The subsequent error message "fatal: no submodule mapping found in .gitmodules for path 'script'" reiterates that the submodule 'script' is not properly mapped in the .gitmodules file.
This file should contain the necessary information about the submodule, such as its repository URL and the relative path where it should be located within the parent repository.
Solution
To resolve this issue, you should check the .gitmodules file in the parent repository and ensure that there is an entry for the 'script' submodule. Verify that the mapping is correct, including the relative path to the submodule's location. If the entry is missing or incorrect, you'll need to update it accordingly.
After making the necessary changes to the .gitmodules file, commit the changes and try the checkout process again. This should allow Git to properly initialize and update the submodule during the checkout process.