GitHub + VSTS Open source code bidirectional synchronization

Source: Internet
Author: User

GitHub is already home to the world's Open source code, and you can see that only JavaScript has more than 320,000 activities on GitHub at repo. Many developers will share their own part of the code to open source on GitHub, on the one hand can improve their visibility in the field of programming, but also to attract other developers to help you improve together, of course, you can know more friends, or how to say that GitHub is actually a dating site.

But the free repo on GitHub can only be public, and for some projects that we don't want to be fully open source, there's no way to share it for free, and you can, of course, pay to upgrade to the Pro version so you can host a private repo.

Visual Studio Team System is a free enterprise software development SaaS service provided by Microsoft, offering free private git repo services. Many of my friends around me are hosting projects of my own or my company on VSTS, and part of it is open source.

Combining GitHub's free public repo and free private repo on VSTS, we can build a combination of internal and external open source code development platforms that let us control which code is open source and accept community contributions to open source code. Common scenarios include:

    • The master branch of the private repo is synchronized with the master branch of the public repo, supporting the sharing of the main distribution with the community and accepting the PR.
    • Two-way synchronization of a specific branch of a private repo with the master branch of the public repo, supporting the sharing of specific distributions with the community, accepting PR, and incorporating a new round of PR into the private master branch.
    • Supports differentiated publishing of private and public distributions.
    • Supports automatic and manual synchronization.
Create a CI on VSTS to complete the synchronization configuration

The CI engine on VSTS has built-in support for the git that comes with GitHub and VSTS itself, and with this feature we can easily establish a synchronization mechanism.

1. Create a sync job from VSTS to GitHub

Build a build definition, use empty template, select Repo on VSTS as the source of code

Add 2 command line tasks on the inside, and configure the following commands separately

Git pull Https://github.com/ups216/vsalm-hols.git mastergit push https://$ (Githubtoken) @github. com/ups216/ Vsalm-hols.git Head:master

You will notice that in the second command I used a parameter called $ (githubtoken). You can generate such a personal Access Token from GitHub and use the following page to bind to the build definition so that the user does not see the specific content of the token at run time.

Note the lock callout pointed to by the arrows in the diagram, and VSTS stores the key in an encrypted manner to ensure that the user does not see the content.

2. Build a sync job from GitHub to VSTS

The configuration process here is reversed, and in the first step we create a build definition that gets the code from GitHub

Then run the following two commands

Git pull https://$ (Vststoken) @almnetworks. Visualstudio.com/defaultcollection/_git/vsalm-hols mastergit Push https:/ /$ (Vststoken) @almnetworks. Visualstudio.com/defaultcollection/_git/vsalm-hols Head:master

You'll notice that the $ (vststoken) parameter is used on both pull and push commands because the repo on the VSTS we operate on is a private repo, and both reads and writes require authentication.

Set up the above configuration we can test this bidirectional synchronization process, the following is the test video:

The above is the simplest true two-way synchronization configuration for the master branch, and if you need to synchronize a specific fraction, we only need to make simple changes to the git command.

Please follow the public number "Devopshub" For more information on DevOps integration

?

GitHub + VSTS Open source code bidirectional synchronization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.