Command was canceled: command git failed with code -1

Still need help?

The Atlassian Community is here for you.

Ask the community

Problem

Whenever a build is triggered, the Source Code Checkout task fails and the following error is observed in the <BAMBOO_HOME>/logs/atlassian-bamboo.log file (or <BAMBOO_AGENT_HOME>/atlassian-bamboo-agent.log file if running on a remote agent):

[GitCommandProcessor] Command was canceled: command 'C:\Program Files (x86)\Git\cmd\git.exe' <insert-git-command-here> failed with code -1. Working directory was [\].

The problem may also occur at change detection time, before a build is even dispatched to the agent. This can cause the build to appeared as queued for lengthy period before eventually hitting the command timeout or fail instantly with the above error depending on the cause.

Diagnosis

Diagnostic Steps

  1. Does the failure happen quite quickly? 
    1. Yes, the command fails almost instantly when performing git version. See Cause 1.
    2. No, the command takes anywhere between a minute to hours before it eventually fails when performing git fetch or git ls-remote. See Cause 2.

Cause

  1. The Git capability path in Bamboo is incorrect or the user running the Bamboo or agent process doesn't have permissions to access the git installation path / executable.
  2. The configurable Command Timeout for the Repository under Advanced Options has been reached and the command has been aborted. The default for this setting is 180 minutes however this has been lower in previous versions of Bamboo.

Resolution

Cause 1: The Git capability path in Bamboo is incorrect or the user running the Bamboo or agent process doesn't have permissions to access the git installation path / executable

  1. Check where Git is actually installed on the machine where the build is running (local agents run on the same machine where Bamboo is running, remote agents usually run on separate machines). 
    1. If the Git location was added to the system path, it's possible to run "which git" from the Terminal (Unix) or "where git" from a Command Prompt (Windows) to check the path to the installation directory.
  2. Go to Bamboo and check the Git capability path as defined for the local Bamboo Server or agent machine. Check Viewing a capability page on how to locate this information.
  3. If there is mismatch between where Git is installed, compared to the capability path configured in Bamboo – update the capability in Bamboo to the correct path.
  4. Ensure that the user running the Bamboo or agent process has full access to the git executable at the installed path.

Example

From the error message above, the Git capability path in Bamboo is pointing to:

C:\Program Files (x86)\Git\cmd\git.exe

After running "where git", on the Command Prompt, from the agent machine, the following is observed:

C:\Program Files\Git\cmd\git.exe

After updating the Git capability path in Bamboo (Viewing a capability) to the correct location, builds started working.

If Bamboo service or the remote agent is running on a Windows machine and you're using a Bamboo version below 6.10, it's possible that you are also being affected by the situation described at the Remote agent running as a Windows Service does not pick up the PATH variable correctly documentation.

Cause 2: The configurable Command Timeout for the Repository under Advanced Options has been reached and the command has been aborted.

  1. If you have a large repository that takes longer than the command timeout to perform the initial clone under normal circumstances, you may wish to increase the configured command timeout to allow Bamboo enough time to perform the fetch. This can be done at:
    1. Plan Configuration > Repositories > repository > Advanced Options > Command Timeout
  2. Investigate any network issues that may be causing the fetch from the repository to take longer than expected.
  3. Git Credential Manager for Windows under certain circumstances has been known to cause issues where the command hangs while waiting for user input / interaction (which cannot occur in an automated fashion) until the Command Timeout is eventually reached. This will typically affect the initial git ls-remote. See the below improvement request for workarounds:
    1. BAM-18205 - Getting issue details... STATUS

Last modified on Dec 5, 2019

Was this helpful?

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