Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSTS build from multiple repositories

I have two repositories - one in TFVC and another in Git. There are specific technical reasons for keeping them separate.

The code in TFVC is built on a private build agent and the code in Git is built on a hosted agent. So currently I have two independent builds and the outcomes of them are deployed together in a release definition.

I am looking at creating builds that may be able to get the source from both the repositories so that I have a single build definition to manage.

Is there a way to achieve this?

like image 865
Kangkan Avatar asked Mar 30 '18 09:03

Kangkan


2 Answers

For now, there is no way to specify multiple repositories in Get sources step. And there has an user voice Allow TFS build to depend on multiple repositories which suggests similar feature, you can vote and follow up.

The workaround for now is manually get the files from the other repo.

Such as, if you specify TFVC repo in Get sources step, then you can add a PowerShell task at the beginning of the tasks, and clone the other git repo by git clone <repo URL> etc.

like image 86
Marina Liu Avatar answered Oct 11 '22 13:10

Marina Liu


TFVC

And the inverse of Marina's answer is also possible. After binding your build definition to Git by default, you can add a powershell script to map a workspace and fetch the sources:

tf workspace /new /noprompt /location:local /permission:private <name>
tf workfold /map $/Server/Path "$(Agent.BuildDirectory)\tfvc" /workspace:<name>
tf get "$(Agent.BuildDirectory)\tfvc"

And add a "always run task" to clean up the workspace afterwards:

tf workspace /delete <name>
rd /s /q "$(Agent.BuildDirectory)\tfvc"

Download artifact

Another option is to use the Download Artefact task to download the artifacts from the following extension: TFS Artifacts for Release Management.

Or the Download Artifact task that comes with VSTS, though that one requires a link to a Build Definition to download from, which means you could have a CI build on either Git or TFVC that build the sources, or simply attaches the sources directory, then fetch those in the "other" build.

like image 41
jessehouwing Avatar answered Oct 11 '22 13:10

jessehouwing