我有一个存放在VSTS上的存储库,包含一个通过git-lfs存储的文件。如果我只是让VSTS构建签出存储库,它只是下载包含文件ID的git-lfs元数据文件。
下面是VSTS获取其源的输出:
Syncing repository: MyRepo (Git)
Checking out c84ef2f2bbad4fa3dc70dbd4100534390b9c8f18 to d:\work\73\s
Checked out branch refs/heads/develop for repository MyRepo at commit c84ef2f2bbad4fa3dc70dbd4100534390b9c8f18我需要做些什么来检查真正的文件?
编辑:我想我需要在VSTS签出源代码后手动调用git lfs fetch。但是在这种情况下,我如何处理身份验证(这是VSTS所要求的)?
发布于 2017-03-25 23:15:50
这一进程再次得到更新(2017年3月)。这一次,您需要编辑构建定义的“获取源”部分。在右上角启用“”选项,并选中“从LFS签出文件”选项。

发布于 2016-03-08 19:29:01
更新
VSTS现在支持开箱即用的git。这只是激活构建定义中的选项Repository / Checkout files from LFS的问题。它比下面的解决方案简单得多。
我尝试了Pascal的启用Git远程访问构建任务,但是我无法使它工作。调用git-lfs.exe不会崩溃,但它不会将LFS文件转换为真正的文件。
这是我如何使它工作。我首先必须在构建定义中启用Allow Scripts to Access OAuth Token选项。然后,我创建了一个PowerShell脚本来提取LFS依赖项:
# Inspired from here: http://ss64.com/ps/syntax-set-eol.html
function Set-UnixLineEndings([string]$file)
{
# Replace CR+LF with LF
$text = [IO.File]::ReadAllText($file) -replace "`r`n", "`n"
[IO.File]::WriteAllText($file, $text)
# Replace CR with LF
$text = [IO.File]::ReadAllText($file) -replace "`r", "`n"
[IO.File]::WriteAllText($file, $text)
}
if ((Test-Path env:SYSTEM_ACCESSTOKEN) -eq $false)
{
throw "OAuth token not available. Make sure that you select the option 'Allow Scripts to Access OAuth Token' in build 'Options' pane."
}
# git lfs needs the credentials of the git repository. When running
# under VSTS, these credentials are transfered to the git-lfs.exe
# application using the oauth token provided by VSTS. These
# credentials are stored in a file so that git lfs can find them.
$pwPath = Join-Path $PSScriptRoot pw.txt
$gitPwPath = $pwPath.Replace('\', '/') # Needs to be in unix format.
$repoUri = New-Object Uri $env:BUILD_REPOSITORY_URI
git config credential.helper "store --file=$gitPwPath"
@"
https://OAuth:$env:SYSTEM_ACCESSTOKEN@$($repoUri.Host)
"@ | Set-Content $pwPath
# Again, needs to be in unix format... sigh...
Set-UnixLineEndings -file $pwPath
& ".\git-lfs.exe" pull
if ($LASTEXITCODE -ne 0)
{
throw 'Failed to pull LFS files.'
}这显然假设您已经在git存储库中存储了git-lfs.exe,并且LFS没有跟踪该文件。
发布于 2016-10-23 15:34:52
更新
我确认程序已更改,请忽略以下答案。
我不得不说我只是发现:
在构建定义中,选择存储库选项卡,并检查来自LFS的签出文件选项。
再简单不过了。
https://stackoverflow.com/questions/34083386
复制相似问题