Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

azure devops - How to synchronize VSTS and Github respositories when commits are made

I have a repository in visual studio team services that I would like to keep synchronized with a github repository.

This allows me to do my main development in VSTS and when merging into master it will be synced to github and also allow others to contribute on github and when there Pull Requests are merged into master its synced to VSTS.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

First create a new build on VSTS that is using the repository that should be synced from VSTS:

VSTS Build

add two CMD tasks that will run some git commands. git pull remote enter image description here

where the last of the two needs a personal access token from Github.

In the images both CMD tasks uses the GIT tool and the following two commands:

pull https://github.com/s-innovations/MessageProcessor.ServiceFabric.git master

and

push https://$(githubpersonaltoken)@github.com/s-innovations/MessageProcessor.ServiceFabric.git head:master

Enable the CI option to trigger the build to run whenever something is commited to master.

Now the same can be done the other way, where a new build is made the same way but with the urls changed to target visual studio online repository.

push to vsts

Do note that when using personal tokens on vsts the authentication part of the url needs to be https://:token@ and on github its just https://token@.

push https://$(vstspersonaltoken)@sinnovations.visualstudio.com/DefaultCollection/S-Innovations%20MessageProcessor/_git/messageprocessor-service-fabric head:master

Update AUG 2017

They changed it at VSTS, such if the colon is present it will fail auth. The above description have been updated.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...