Search code examples
azure-devopsazure-pipelinesgit-lfs

How to use git lfs with Visual Studio Team Services hosted build agents


I use git lfs to store the large files of my git repo. I then try to build this repo with hosted agents. My build is pretty simple. It has a single task: Execute PowerShell. In the invoked script, the first thing that I want to do is to fetch my lfs dependencies. I therefore have the following in my script:

& git lfs fetch

Unfortunately, my build fails with the following error:

2016-03-04T19:49:05.7021988Z ##[error]git: 'lfs' is not a git command. See 'git --help'.
2016-03-04T19:49:05.7031986Z ##[error]Did you mean this?
2016-03-04T19:49:05.7041987Z ##[error]  flow

Since I can't install anything on hosted agents, how am I supposed to have git lfs available?

EDIT In this issue, I am not talking about git lfs authentication problems as described here. I am strictly talking about the issue of calling git lfs.

Once you are able to call git lfs, look at this answer to solve the authentication problem.


Solution

  • You get this error message because git-lfs isn't installed on Hosted Build Agent by default.

    And since you are using Hosted Build Agent, it would be a little troublesome to install git-lfs via Chocolatey on it as you don't have administrator permission. An alternative way would be download the binary files for git-lfs directly and upload it into Source Control. Then you can invoke the git-tfs.exe with an absolute path in your script.