Bamboo build fails with error "git: 'lfs' is not a git command"
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the server and data center platforms.
Summary
Bamboo will try to build a build plan the requires git lfs, in a remote agent where git lfs is installed, and fails with the error "git: 'lfs' is not a git command".
Environment
Bamboo running with at least one remote agent.
Diagnosis
When the build is sent to the remote agent, the build will fail and in the server logs we will see:
com.atlassian.bamboo.repository.RepositoryException: : Cannot fetch branch 'feature/branch1' from 'ssh://git@gitserver:7999/project/repository.git' to source directory '/app/bamboo/bamboo-home/xml-data/build-dir/_git-repositories-cache/328a912ef82c8415aa64f494d23dbae966f741dc'. command [/app/bamboo/bamboo-home/git/bin/git lfs logs last] failed with code 1. Working directory was [/app/bamboo/bamboo-home/xml-data/build-dir/_git-repositories-cache/328a912ef82c8415aa64f494d23dbae966f741dc]., stderr:
git: 'lfs' is not a git command. See 'git --help'.
Cause
Even if the build is trying to be built in a remote agent, the problem relies on the server itself. Bamboo server requires git lfs installed, even though there are no local agents configured. The reason for this is that Bamboo will perform a fetch before dispatching the build, an this is the actual operation that fails.
There can be cases where there is a plan that requires git lfs and still works fine, even though git lfs is not installed in the server. If you see this case, it is working because git lfs was not configured from the start, and Bamboo was able to create a local cache of the repository, making the fetch not necessary.
Solution
Install git lfs in Bamboo server.