Syncing my Github repo to MS Visual Studio Team Se

2019-08-03 08:10发布

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:

enter image description here

I create a new definition of Builds

enter image description here

link it to my github repo

enter image description here

set access tokens

enter image description here

set task commands just as stated in the tutorial link above

enter image description here

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

2条回答
Summer. ? 凉城
2楼-- · 2019-08-03 08:54

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:

    enter image description here

  • 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:

    enter image description here

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

查看更多
甜甜的少女心
3楼-- · 2019-08-03 08:57

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.

Build Definition Triggers

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

查看更多
登录 后发表回答