fatal: Not a git repository, GIT_DISCOVERY_ACROSS_FILESYSTEM not set error seen on Bamboo Data Center

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.

Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles 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

Summary

The following exception appears during any of the below events:

  • Remote agent running the builds and performing source code checkout task
  • Bamboo runs change detection as part of a Plan or for its automated actions
Cannot fetch branch 'BRANCH_NAME' from 'REPO_URL' to source directory '/var/atlassian/application-data/bamboo/xml-data/build-dir/_git-repositories-cache/HASH'. command /usr/local/bin/git fetch URL +refs/heads/develop:refs/heads/develop --update-head-ok failed with code 128. Working directory was [/var/atlassian/application-data/bamboo/xml-data/build-dir/_git-repositories-cache/HASH]., stderr: fatal: Not a git repository (or any parent up to mount point /mnt) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
  • While running repository tagging task in Bamboo
error Caused by: com.atlassian.bamboo.plugins.git.GitCommandException: command [/usr/bin/git log -1 --encoding=UTF-8 --format=%H HEAD] failed with code 128. Working directory was [/var/atlassian/application-data/bamboo-agent/xml-data/build-dir/SCRIP-TIC-JOB1/tesrepo1]., stderr:
error fatal: not a git repository (or any parent up to mount point /var/atlassian/application-data)
error Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

Environment

The issue was seen on Bamboo 9.6.4 but the solution can be applicable for any other supported version as well. 

Diagnosis

  1. Check if there is any special character in the branch name
  2. Run the command "locale" on the server to confirm if it is using UTF-8 or en_US.UTF-8 encoding
  3. Please run the following command to check that the specific cache directory and its contents exist and are accessible by the user which is running the Bamboo service or on the agent depending upon where the error occurs. 

    ls -alR <bamboo-home>/xml-data/build-dir/_git-repositories-cache/HASH/.git

    (info) Please be sure to replace the above path with the path which you get in the error message. 

Cause

Cause 1

  1. Remote agent is not using file encoding UTF-8

Cause 2

  1. The machine is not using UTF-8 or en_US.UTF-8. The configured locale does not work well in the machine

Cause 3

  1. Bamboo server being unable to access the .git directory in the local repository cache on the Bamboo server
  2. If the problem is seen during the repository tag task probably the folder where the checkout has happened has been moved before the repository tagging task is executed. 

Solution

Solution 1

Restart remote agent with the following file encoding setting in REMOTE_AGENT_HOME/conf/wrapper.conf file:

wrapper.java.additional.3=-Dfile.encoding=UTF-8
wrapper.java.additional.4=-Dsun.jnu.encoding=UTF-8

(info) Please make sure to replace 3,4 with the next available number depending upon how many parameter are available already.

Solution 2

Configure the machine locale to be UTF-8 or en_US.UTF-8, refer this for more details

Solution 3

  1. Delete the affected local cache directory in Bamboo server and on the agent, refer Git cache removal in Bamboo for more details
  2. If the problem is seen while running any git related task for example repository tagging task, make sure the folder where the checkout happened has not moved after the checkout has happened and before the repository tag task is executed and the user which is running the agent has full permission to these folders. 

Last modified on Sep 25, 2024

Was this helpful?

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