Not download Few Folders of Azure DevOps Repo in Azure DevOps CI Pipeline

608 Views Asked by At

I have Created a CI Pipeline in Azure Devops. My Repo is Azure DevOps Repo.

My Repo size is big so i do NOT want some of Folders to be downloaded on agent machine as Those folders are redundant for code build.

What changes i need to do in my pipeline yaml file?

enter image description here

for example FolderX should not be downloaded

2

There are 2 best solutions below

0
On

It will clone the whole repository content even you add .gitignore.

You could customize the checkout step via Command line task with "git sparse-checkout".

Sample as below:

trigger: none

pool:
  vmImage: ubuntu-latest

steps:
- checkout: none
- script: |
    git init $(System.TeamProject) && cd $(System.TeamProject)    
    git config core.sparsecheckout true
    echo '/*' >> .git/info/sparse-checkout
    echo '!testfolder2/*' >> .git/info/sparse-checkout
    git remote add origin https://anything:$(PAT)@dev.azure.com/{yourorg}/{yourproject}/_git/{yourrepo}
    git pull origin main
    git checkout main && ls

enter image description here

You can find similar link here and here.

0
On

You cannot specific exclude folders during cloning. At present time, Azure DevOps does not support Git blob filters.