Branch Merging through azure Dvops build pipeline

Viewed 25

We are using TFS (or TFVC) as version control system in Azure Devops. I have a requirement like merging two branches of this version control system through Azure Devops build pipeline which is running on a self-hosted agent(i mean we installed agent on a server). Below is the code i have written to do this, but it is not working at all even the pipeline is running fine. What is the mistake i am doing here... Please guide.

Also, after merging i want to check-in the code in the target branch by linking to common work-item. how can I achieve this...

Set-Location "$(System.DefaultWorkingDirectory)"

Start-Process "tf.exe" "workspace /new /noprompt /collection:https://dev.azure.com/ATDAzureSQL/" -Wait

Start-Process "tf.exe" "merge $/CRS_ITP2_2_1/Test01 $/CRS_ITP2_2_1/Test02 /recursive /noprompt /loginType:OAuth /login:.,$(System.AccessToken)" -Wait

Start-Process "tf.exe" "checkin $/CRS_ITP2_2_1/Test02 /comment:Automerge /recursive /noprompt" -Wait

1 Answers

If you check the checkout step in your build, you`ll find using PAT in all commands:

enter image description here

This script works:

tf.exe merge `$/TestProject/dev `$/TestProject/main /recursive /noprompt /loginType:OAuth /login:.,$(System.AccessToken)

tf.exe checkin `$/TestProject/main /comment:Automerge /recursive /noprompt /loginType:OAuth /login:.,$(System.AccessToken)

enter image description here

The result:

enter image description here

enter image description here

Related