MydKnight
MydKnight

Reputation: 301

Integrating VSTS with Github

I'm trying to use VSTS to manage my project/code/bugtracking for a python based project I'm working on. The code is stored in github. What I'm trying to do is to set up VSTS such that when I push new commits from my local (which is edited in pycharm, committed locally, then pushed to github) these changes reflect in VSTS. I've been able to clone the repo into vsts, but it never sees any further changes I make in PyCharm. Ideally, I'd like to be able to reference stories/bugs/etc from vsts when i do a PyCharm commit, and then on refresh in VSTS I'll see that bug mark closed, commit made, etc.

At this point however, any changes that i push to github are not reflected in VSTS...how do I need to set this up so that changes in my github repo are reflected in vsts directly?

Upvotes: 0

Views: 870

Answers (2)

Shayki Abramczyk
Shayki Abramczyk

Reputation: 41545

From your comment, I see that you realized that mirroring is not a good idea.

So you can use VSTS build and get directly the GitHub repo:

enter image description here

If you want use PyChram for VSTS work item tracking you can install Visual Studio Team Services Plugin that compatible with PyChram.

Upvotes: 1

Marina Liu
Marina Liu

Reputation: 38096

You can use a VSTS CI build pipeline to sync VSTS git repo with github repo.

Details as below:

Create a new build pipeline -> Add a PowerShell task -> Triggers Tab -> Enable continuous integration -> Include all branches by refs/heads/*.

enter image description here

In the PowerShell task, use below script to sync changes from GitHub repo to VSTS git repo:

if ( $(git remote) -contains 'vsts' )
{git remote rm vsts
echo 'remove remote vsts'
}

$branch="$(Build.SourceBranch)".replace("refs/heads/","")
git remote add vsts https://Personal%20Access%20Token:[email protected]/project/_git/repo
git checkout $branch
git push vsts $branch -f

Note: you need to provider access to VSTS git repo in the VSTS git repo URL. As below script, you can provider PAT for authentication.

Then, save the build pipeline. And when there has new changes push to your GitHub repo, a CI build will be triggered and changes from GitHub repo to VSTS Git repo after executing PowerShell task.

Besides, you can also refer this post for similar situation.

Upvotes: 0

Related Questions