Warm tip: This article is reproduced from serverfault.com, please click

How to git clone on Azure self hosted agent and powershell without creating a local repo

发布于 2020-11-27 17:10:08

I am new with Git and would need some help. Working on Azure pipelines, I created few PowerShell scripts, hosted in an Azure files git repo. When the pipeline starts, on the Windows Self-hosted agent, I want a PowerShell script to download the latest version of the scripts in the git repo.

I tried:

E:
CD myFolder
git clone --no-checkout https://token@acme.visualstudio.com/DefaultCollection/Project/_gits/fileRepos

But it only creates the _git folder and an empty structure

The fileRepos is structured like this: 
- fileRepos
  - Scripts
    - File 1
    - File 2

I don’t want to create a local repos or keep tracking of the files, I only want to download the files. In addition on my agent, I would want this structure:

e:\myFolder
  - Scripts
    - File 1
    - File 2

Could you please help me? Thanks

Questioner
ClaudeVernier
Viewed
0
Leo Liu-MSFT 2020-11-30 14:10:30

How to git clone on Azure self hosted agent and powershell without creating a local repo

We could add a copy task in the pipeline to remove the fileRepos folder with following git clone command:

D:

cd myFolderTemp

git clone https://PAT@dev.azure.com/<YourOrganizationName>/<YourProject>/_git/TestSample

Then add copy task to copy the files from the temp folder myFolderTemp to myFolder without the .git folder:

enter image description here