0

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?

MydKnight
  • 301
  • 2
  • 12
  • 1
    So you want to have a repo in VSTS that mirrors the repo on GitHub? Why? For instance if you want to create a build pipeline in VSTS you can directly get the resources from GitHub. – quervernetzt Aug 11 '18 at 07:53
  • 1
    And if you really want to do that maybe go with GitHub Web Hooks and something like an Azure Function using the VSTS REST API to sync the changes. – quervernetzt Aug 11 '18 at 08:00
  • 1) project/code/bug tracking can also be done on GitHub natively (Visual Studio Code illustrates that) 2) like others' commented, you don't have a trigger configured yet, so your GitHub/VSTS repos won't sync. 3) @quervernetzt does show one workaround, and you can also use a service like Zapier (instead of Azure Function) as trigger. – Lex Li Aug 11 '18 at 13:24
  • Ok, so mirroring doesn't sound d like a good idea to me either now that you talk about it that way. Getting the resources directly from GitHub would sound like the closer thing to what I want...so I'm going to need to research build pipelines it seems. Basically I want to use vsts to track work items and tie them to the actual code in GitHub – MydKnight Aug 11 '18 at 17:15
  • 1
    @MydKnight My recommendation: Choose one platform. – Daniel Mann Aug 11 '18 at 19:46

2 Answers2

1

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.

Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
  • This seems closer to what I'm thinking about wanting to do. I have to confess that the whole build part of VSTS is still QUITE confusing to me. It seems I have to do a build on VSTS to get things to sync up from my local to remote, however I have very little understanding of how that works. I've tried doing it a few times and it seems to have done what I want, but at a High level, I really don't know what its doing. Perhaps its time to go watch a few youtube videos. – MydKnight Aug 27 '18 at 17:58
0

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:PAT@account.visualstudio.com/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.

Marina Liu
  • 36,876
  • 5
  • 61
  • 74