Vahid Farahmandian
Vahid Farahmandian

Reputation: 6568

Upload changes from AzureDevOps git repo to private TFS server using Build/Release pipeline task

I have a GIT repository hosted on dev.azure.com(AzureDevops), and a local TFVC repository hosted on a private server(I do not have access to machine, I just have access to its Web Portal). Both have the same code.

I have created a build and release pipeline for my GIT repository in AzureDevops, which is working well. But now, I want to update my TFVC repository from GIT repository, as a Build/Release pipeline task each time the pipeline executed in AzureDevops.

There is not any probability for possible conflict, as no one else will check-in changes to my TFVC repository.

Is there any way to achieve this?

Upvotes: 1

Views: 316

Answers (3)

Etienne
Etienne

Reputation: 1100

What I would do is add a remote to your Azure DevOps service repo that points to you internal TFS (as long as you internal TFS is visible from the internet) then in your build (in the service) you can just call git push internalorigin. Now if you can't see you internal TFS from the web then like Cece mentionned, install a build agent on your TFS server and in the build create an agent step and then call an inline powershell to add a remote and then call git push internalorigin something like this

multi agent build

Then in the script you can do something like this

git remote add internalorigin https://TFSSERVER/COLLECTION/_git/REPO
git push -u internalorigin --all

UPDATE:

Got from Git to TFVC your inline script would copy the local files from the build to your local TFVC workpace and then use TF.exe to checkin something like this

copy c:\agent\_work\1\s c:\workspace /Y
cd c:\workspace
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\Team Foundation\Team Explorer\TF.exe" vc checkin /comment:"comment" /noprompt /recursive *

Your going to have to try it from the command line first make sure it works then put it in the inline script.

Upvotes: 2

pabrams
pabrams

Reputation: 1164

Do what Etienne said, but if your target repo is tfvc, Add command line tasks to your pipeline that use tf.exe (instead of git) to upload and commit to your tfvc repo, and manage the workspace.

Upvotes: 1

Cece Dong - MSFT
Cece Dong - MSFT

Reputation: 31013

You may deploy a self-hosted agent on your TFS repository machine. And add a script task in the Build/Release pipeline to update the repository.

Upvotes: 1

Related Questions