From f9063fbbfd7912c79c747c282fd649bc60b63ef0 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Thu, 29 Apr 2021 10:25:06 -0700 Subject: [PATCH] Set multiple sparse checkout paths in one command/job (#841) Co-authored-by: Ben Broderick Phillips --- .../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 5d06154d6..b7dfa79a8 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)) }}