Check git-lfs files on VSTF assembly

I have a repository hosted in VSTS containing a file stored through git-lfs. If I just let VSTS build a repository check, it will just load the git -lfs metadata file containing the file identifier.

Here's the conclusion how the VSTS source gets its source:

Syncing repository: MyRepo (Git)
Checking out c84ef2f2bbad4fa3dc70dbd4100534390b9c8f18 to d:\work\73\s
Checked out branch refs/heads/develop for repository MyRepo at commit c84ef2f2bbad4fa3dc70dbd4100534390b9c8f18

What do I need to do to check the real file?

Edit: I assume that I need to manually call git lfs fetchafter VSTS checks the source. But how can I handle authentication (which is required by VSTS) in this case?

+4
source share
5 answers

( 2017 ). " " . " " " LFS".

enter image description here

+5

VSTS git LFS . Repository / Checkout files from LFS . , .


Pascal git Remote Access, . git -lfs.exe , LFS .

. Allow Scripts to Access OAuth Token . PowerShell script, 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 -lfs.exe git LFS.

+4

, , , .


, , :

LFS

.

+3

VSTS Allow Scripts to Access OAuth Token. , , OAuth .

, URL, OAuth .

0

TFS Build 2015 Update 4 ( , VSTS, ), "Checkout files from LFS" ,

  • Allow Scripts to Access OAuth Token "".
  • -:

    REM This script is intended to fetch large (LFS) files during the TFS Build process.
    
    REM Solution derived from https://github.com/Microsoft/vsts-agent/issues/1134
    
    git config --unset-all http.extraheader
    git config --add http.extraheader "AUTHORIZATION: bearer %SYSTEM_ACCESSTOKEN%"
    git lfs fetch
    git lfs checkout
    git config --unset http.extraheader        
    
  • Batch Script script.

0

Source: https://habr.com/ru/post/1618545/


All Articles