From b1bf4e88e26261a4ca0e7aa6abd3a57e2a359ed5 Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Tue, 27 Apr 2021 16:34:30 -0400 Subject: [PATCH] Set multiple sparse checkout paths in one command/job --- .../pipelines/templates/steps/sparse-checkout.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/eng/common/pipelines/templates/steps/sparse-checkout.yml b/eng/common/pipelines/templates/steps/sparse-checkout.yml index 5d06154d6655..b7dfa79a807a 100644 --- a/eng/common/pipelines/templates/steps/sparse-checkout.yml +++ b/eng/common/pipelines/templates/steps/sparse-checkout.yml @@ -24,15 +24,13 @@ steps: - pwsh: | git clone --no-checkout --filter=tree:0 git://github.com/${{ repo.Name }} . git sparse-checkout init - git sparse-checkout set eng + $paths = ('${{ convertToJson(parameters.Paths) }}' | ConvertFrom-Json) -Join ' ' + Invoke-Expression -Command "git sparse-checkout set eng $paths" + Write-Host "Set sparse checkout paths to:" + Get-Content .git/info/sparse-checkout displayName: Init sparse checkout ${{ repo.Name }} workingDirectory: ${{ coalesce(repo.WorkingDirectory, format('{0}/{1}', '$(System.DefaultWorkingDirectory)', repo.Name)) }} - - ${{ each path in parameters.Paths }}: - - pwsh: git sparse-checkout add ${{ path }} - displayName: Add sparse checkout path ${{ path }} - workingDirectory: ${{ coalesce(repo.WorkingDirectory, format('{0}/{1}', '$(System.DefaultWorkingDirectory)', repo.Name)) }} - - pwsh: git checkout ${{ repo.Commitish }} displayName: Sparse checkout at ${{ repo.Commitish }} workingDirectory: ${{ coalesce(repo.WorkingDirectory, format('{0}/{1}', '$(System.DefaultWorkingDirectory)', repo.Name)) }}