5

I need to regularly download a complete set of latest code for a particular project from a VSTS account (server workspace), to a folder on a file server for readonly archiving.

Currently I log on to the web portal and click Download as ZIP for the selected project and save this to the file server.

But I'd like a more automated way, preferably something I can schedule to run from the file server itself which won't have Visual Studio installed or cached credentials for the online account.

Any of the following soluions would be ok:

  • A permanent URL to download the latest code as a zip file
  • A REST URL to get all latest files
  • A command line tool to connect to the VSTS account and download all latest files for a particular project to a specified local folder, not the default local folder

Nice to have:

  • Option to download as ZIP or recursive folder of files
  • Set files modified date as check-in time
  • Remove source control binding information from the downloaded files
  • Provide user credentials as part of the command line, not assume to use the default cached credentials on the machine
Community
  • 1
  • 1
userSteve
  • 1,554
  • 1
  • 22
  • 34

3 Answers3

3

You could use our tools in Visual Studio, Eclipse, or from the command line to keep a local copy of your source code on your machine.

More details please refer official tutorial: Download (get) files from the Server

Also, if you want to download your code as a zip:

You can click on any ellipsis to find the menu which contains Download as Zip option.

enter image description here

If you want a automated way, suggest you use the build pipeline. You could disable the default get source steps in the build definition. And use your own powershell script to do the get source/pull files to the workspace. How to, please follow: Is it able to ignore/disable the first step Get source in vNext Build?

This will download files in your build agent, if it's not the machine you are working on. You could combine Archive Files & Windows Machine File Copy task and select Scheduled trigger in your build definition.

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • Thanks @PatrickLu-MSFT but it still sounds very complicated and I'm unable to download the code to a folder of my choosing. I'm very suprised that although its possible to download a zip of the complete code manually, this isn't offered through a command line. Am still looking into another solution. – userSteve Sep 04 '18 at 12:16
  • This is the perfect solution (IMO, I guess) to the question. It's fully automated, and allows you to put the source in a directory of your choice. @userSteve, if it seems complicated, I suggest you get to know the Azure DevOps interface. It is MUCH simpler that it seems once you understand the data flow. – CrazyIvan1974 Mar 01 '19 at 22:15
  • I'm looking to do the same thing. Bitbucket makes this super easy. Issue a GET to https://bitbucket.org/myusername/myproject/get/branch-name.tar.gz and it downloads it and omits source control binding information. Very straightforward with `curl`; it does not get much easier than this. – Erich Musick Apr 21 '19 at 19:35
0

you might consider using an agent + build definition to download the source code (this could happen either based on a schedule or triggered after every check-in). This could easily include compression to a ZIP file and some copy commands.

An additional benefit would be that the build definition doesn't have to re-download the entire source code repository each time it is run - instead, it can be configured to just download get the changes that occurred.

Jundiaius
  • 6,214
  • 3
  • 30
  • 43
Neno
  • 1
  • Thanks but I'm not sure what you mean by agent definition. Can you give an example? – userSteve Sep 04 '18 at 12:12
  • @userSteve: Step 1: [Set up a VSTS Agent](https://learn.microsoft.com/en-us/vsts/pipelines/agents/v2-windows). Step 2: [Create a build pipeline](https://learn.microsoft.com/en-us/vsts/pipelines/get-started-designer) (used be called definition until just recently) – Neno Sep 05 '18 at 18:16
0

Powershell

$tfsurl = "https://tfs.alogent.com/tfs"
$collection ="/defaultcollection"
$project = "/MyProject"
$api = "/_api/_versioncontrol/itemContentZipped?repositoryId=&path="
$path = "$/MyProject/Source/Datafolder"

Invoke-WebRequest -UseDefaultCredentials -Uri "$tfsurl$collection$project$api$path" -OutFile ".\DataFolder.zip"
Expand-Archive .\Datafolder.zip
SteveSims
  • 535
  • 6
  • 19