1

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?

Vahid Farahmandian
  • 6,081
  • 7
  • 42
  • 62

3 Answers3

2

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.

Etienne
  • 1,075
  • 5
  • 9
  • 1
    I think his target repo is tfvc, not git. – pabrams Apr 09 '20 at 14:47
  • @Etienne the target repo is TFVC, not git. And also how should I login to target repo via cmd?? – Vahid Farahmandian Apr 10 '20 at 13:35
  • oh, this is not the same, you want to sync from Git to TFVC that's not great, but like @pabrams mentions below you can copy the files in the custom build folder (usually \agent\_work\1\s or something like that) and copy into you local tfvc workspace, then use the tf.exe command line and do a checkin. Not great but it should work if you have not conflicts. – Etienne Apr 11 '20 at 21:05
1

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.

Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39
1

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.

pabrams
  • 1,157
  • 10
  • 34