Syncing my Github repo to MS Visual Studio Team Services

↘锁芯ラ 提交于 2019-12-11 06:08:28

问题


I am new to VSTS and trying to sync my Github repos to the VSTS environment to completely integrate my working environment to it. I want to sync my Github repos to update whatever changes made on VSTS. This procedure is very confusing.

I followed this link: http://intranoggin.com/Blog/February-2017/Synchronizing-code-between-GitHub-and-VSTS.aspx

The new interface does not totally reflect the tutorial, but I was able to follow most parts. I did the followings:

I create a new definition of Builds

link it to my github repo

set access tokens

set task commands just as stated in the tutorial link above

save the definition and create a queue that runs the task

This worked well when I made changes a single branch in Github.

But what I am trying to do eventually is:

I want it to sync with the Repo itself including all Branches. So, if I create a new branch for Pull Request, I want it to get applied to VSTS automatically.

I really need help from someone who already has been using VSTS and knows how to make a complete Sync with Github repos and VSTS


回答1:


If you always make changes on VSTS git repo and need to sync github repo correspondingly, then you can use one VSTS CI build definition to achieve it. Detail steps as below:

  • Create a CI build with a PowerShell Task;
  • Select the VSTS git repo in Get sources step;
  • Enable continuous integration andspecify include all branches for Branch filters:

  • Add the powershell script for PowerShell task as below:

    git checkout $(Build.SourceBranchName)
    git remote add github https://username:password@github.com/username/reponame
    git push github $(Build.SourceBranchName)
    
  • Make sure Fail on Standard Error option for PowerShell task is deselected:

Now after any changes is made on the VSTS git repo, github repo will be updated automatically.




回答2:


If you want to build on every branch with VSTS, you need to edit the build definition and then set up an appropriate trigger. This way, builds will happen automatically instead of having to manually queue them.

The official Microsoft documentation on this is pretty good and goes into more detail.



来源:https://stackoverflow.com/questions/50727828/syncing-my-github-repo-to-ms-visual-studio-team-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!