I'm looking for a part-time remote job.

Hire me


I'm the author of:

Mastering Redmine is a comprehensive guide with tips, tricks and best practices, and an easy-to-learn structure.

Check the book's project or

Buy the book

Social pages of the book:

By buying this book you also donate to Redmine (see this page).


Follow me:

SCM Creator 0.5.0b with Github support

This is the first time the release of SCM Creator comes with the feature, that alone can be the reason for using this plugin. The plugin adds new Github SCM to Redmine! It also allows creating Github repositories and registering Redmine hook on Github.
Added by Andriy Lesyuk over 3 years ago

Download SCM Creator 0.5.0b

Own SCM server has many benefits such as the fully controlled access and security of repositories. But such services as Github, in most cases, provide more features. It’s explainable as many people work on features and ease of use on Github and you will unlikely be able to assign such amount of specialists just for your local SCM server. Therefore, many companies and individuals prefer to use Github for hosting their repositories...

The “virtual” SCM

However, you’re going to have troubles, if you want to use Github repositories with (pure) Redmine... While Redmine does supports Git (the backend SCM, which is used by Github) it does not support remote Git repositories! So, Github fans are forced to manually make local mirrors of their Github repositories especially for Redmine (as described here). This procedure, actually, looks similar to what SCM Creator automates for other SCMs, doesn’t it?.. So, I asked myself: Why would not we automate this too? That’s how SCM Creator got Github support!

SCM Creator 0.5.0b adds Github as a new SCM (while, actually, it is not new SCM – it’s Git, in fact). I call this new SCM “virtual”. It gets registered in the system at the same level as Git, Subversion and so on and is listed under the Administration → Settings → Repositories tab:

Repositories tab

It looks similar to Git, because it’s, actually, Git (and that’s why I call it virtual)! Github virtual SCM is used by SCM Creator just to allow Git to make a local mirror of the remote repository. After that the local repository is used as just Git.

Additionally the Github SCM makes SCM Creator update the local mirror from the original remote repository, when the appropriate command is executed by Redmine (read details below)...

The Creator

This way SCM Creator adds another SCM to Redmine... But the main goal of the SCM Creator is different! Remember, we use it to create new repositories? While the local mirror is created for Github, it’s not actually a new repository. But, SCM Creator is also able to create new remote repositories on Github!..

When using Github for hosting your company’s repositories, you usualy have a guy, who is able to login into your company’s account on Github and who creates repositories, when someone requests them. The similar is done by SCM server administrators, if SCM Creator is not installed... That’s when SCM Creator actually helps! And now it does this for Github as well!..

Luckily, Github provides API for creating repositories and this API can be used by SCM Creator to make your life easier (or the life of that guy)! When properly configured SCM Creator adds the beloved “Create new repository” button for Github SCM. This button lets creating remote Github repositories with just one click! So, you only need to make sure, that the “Manage repository” permission is granted to the right guys (role) in your Redmine.

The commits fetching

However, not everything is smooth about Github... As it actually uses the remote repository you may experience performance issues. Similar issues happen, when remote Subversion repositories are used, so these are not new issues and are not specific to Github and, therefore, (luckily) the solution exists...

Git repository form

On the Repositories tab of Administration → Settings page you can see the “Fetch commits automatically” option, which is enabled by default. When this option is checked, Redmine updates the repository (or rereads for local one) each time you access any page under the Repository tab of the project. For remote Subversion and Github this means, that Redmine fetches latest commits from the remote repository, so certainly it’s appreciable.

Sometimes, this process is appreciable for local repositories as well, especially if the local repository is huge. This happens because Redmine also updates the internal cache (which is stored in the database).

So what is the solution?.. First, the “Fetch commits automatically” option must be disabled. Second, the “Enable WS for repository management” option must be enabled.

When the web service for repository management is enabled, Redmine updates repository commits (including the internal cache) only when this was explicitly requested! And this can be requested using the web service client, which is usually put into SCM repository hook or into the cron. For manually mirrored Github repositories (i.e., not what SCM Creator does) it’s also common to use the Github Hook plugin of Jakob Skjerning to update the mirror from the original remote repository. Anyway, configuring this is a quite complex procedure, that requires some manual work, similar to which SCM Creator aims to prevent... So, it prevents this for Github as well!

Github’s Git repository like any other Git repository also supports hooks. Of course, Github does not provide the direct access to repository system files (which is required to use hook scripts), but instead it provides the friendly interface for this. Additionally, it makes it possible to create hooks using Github API – the same API, which SCM Creator uses to create repositories. So, it’s quite possible for SCM Creator to create and configure Github hooks remotely without any manual work... And it does this!

Commits fetching configuration

When the “Register hook for fetching commits” option in the repository form is checked, Redmine also registers the Redmine service hook for the Github repository. The Github’s Redmine service hook was specially designed for Redmine to explicitly trigger the commits fetching, that we have discussed above. This way as soon as you enable this option you can be sure, that Redmine will update its internal commits cache right after new changes are committed to the Github repository. And this works for both: newly created Github repositories and already existing Github repositories! Moreover, this option remains available even for repositories, that have been already added to Redmine...

Certainly, to register the hook SCM Creator must have appropriate permissions for the Github repository. They are granted, if it creates new repository, but for existing ones it needs login and password for the appropriate Github account...

Repositories.png - Repositories tab (38.1 KB) Andriy Lesyuk, 23 May 2014 13:58

RepositoryForm.png - Commits fetching configuration (42.8 KB) Andriy Lesyuk, 23 May 2014 13:58

CommitsFetching.png - Git repository form (19.1 KB) Andriy Lesyuk, 23 May 2014 13:58


Comments

Terms of use | Privacy policy