Managing Repository Integration in Redmine

 |  Feb 11, 23

Repository-in-Redmine.png

Have you known that Redmine, if handled properly, can become an excellent repository manager? If not, continue reading this article, in which we will sort out the question together. .

With the help of this material, you will learn the following:

Code Repository Theory

Code repository is a place where all the versions of IT production are safely stored and supported in the form of files that are available for further distribution across the network.

It is generally of three types:

1) Local: it is hosted on a single machine, so only one user is capable of working with it.

2) Centralized: it is located on a server and several programmers have the access at once.

3) Distributed: the main repository is stored in the cloud and its local copies are available to the developers on their personal computers. When a programmer performs changes in the local version, it is synchronized with the distributed one.

To work with distributed repositories, there is a demand for a convenient platform with a user-friendly interface. Perhaps, the most popular tools for such needs at this moment are Git systems: they allow users to switch between code branches and view commits (the confirmation of code changes), thereby managing the versions of applications.

Migrate to secure hosting

Don't waste your time on Redmine maintenance. Hire experts and focus on your projects

How to Manage Redmine Repository Integration

Now we are going to follow step by step the following ways of configuring repositories in Redmine.

1. Enable SCM

Let’s begin with checking whether the basic integration works correctly. For this reason, go to the Settings page and find the tab called Repositories.

Redmine_1.png

At the top of the screenshot, you see Enabled SCM (Source Control Management – a complete history of all the code changes). If they are installed from sources, the exclamation mark means that a user should make some configuration establishing specific paths to the commands (the text segment below Enabled SCM states this). However, in this case, as in the majority of them, the exclamation mark just signifies that the particular SCM is not installed at all. Once it is installed, a user should restart Redmine and the exclamation marks will transform into the check marks with SCM version numbers in the column Versions:

Redmine_2.png

If there are still exclamation marks near the SCM for some unknown reason, it is advisable to uncheck and disable them. But before a user disables the Filesystem SCM, it is necessary to set scm_filesystem_path_regexp to a regular expression. This way other users with the permission of managing repositories will not be able to read how Redmine is running.

2. Fetch Commits Automatically

Each time users access anything under the projects//repository URL, Redmine fetches new commits or, in other words, shows the changes which happened with the code. It runs smoothly with local repositories, but in case of the remote ones a user should click Fetch commits automatically on the same Repositories tab and disable the default way of updating commits:

Redmine_3.png

Now Redmine suggests two other solutions to visualize all the code updates for distributed repositories.

3. Fetch Commits Using Cron

The first way includes exploiting a special utility called cron. As a tool known for scheduling the automatic execution of commands at concrete intervals, it is also used as a possible trigger for keeping repositories updated with the following command:

$ rails runner "Repository.fetch_changesets" -e production

The default interval is 30 min. The main disadvantage here is that cron can be used only on the same server where Redmine is running.

4. Fetch Commits Using a SCM Hook

The second way is a bit more advanced. It involves hooks, scripts triggered when a user makes a commit to the code repository:

Redmine_4.png

To opt for this option, go to the Repositories settings again and choose the Enable WS for repository management with using the tab Generate a key link. Save changes.

Now it is high time to take advantage of another service and create a hook script for the future SCM:

curl -o /dev/null "URL of Redmine Installation" -d key=Your key> /dev/null 2>&1

On one side, it is more convenient as each project possesses a specific repository running on a particular server. In cases with various SCM, the server supports another parameter, which is id. On the other side, it can sometimes turn out to be troublesome since each repository needs to be configured separately. Still, Redmine updates all the repositories once a commit is performed in any of them.

How to Create Repositories Automatically in Redmine

In comparison to the previous paths, this one is about making Redmine a repository manager, not a browser.

If your project has not had a repository yet, it is time to create one with the help of a special tool titled reposman.rb. It functions the following way: it connects to your Redmine, fetches its projects, tracks whether a repository exists for each of your projects, if not, creates one. However, you should bear in mind two important things: the tool expects that the project's repository shares the exact name with the project itself and the access to the server hosting SCM is required in this case.

Migrate to secure hosting

Don't waste your time on Redmine maintenance. Hire experts and focus on your projects

The next thing is to be aware of the repository’s location and SCM. If the latter one has not been designed yet, just create the path for your repository.

Then you should conform to the FHS by selecting /var/lib/svn as the directory for the Subversion repositories. Test the reposman.rb with this command (do not forget to change the paths, the API key and the hostname):

sudo /opt/redmine/redmine-3.2.0/extra/svn/reposman.rb --owner=www [1] data --svn-dir=/var/lib/svn --url=file:///var/lib/svn --redmine [1] host=mastering-redmine.com --key=oVVm1CmvXJnpRVmTZ5ii --verbose –test

Last but not the least, if everything has worked out, you may use cron for making the command run periodically. Thus, with each new project a new repository will be created automatically.

Repository Integration in Only 10 Minutes

Synchronizing RedmineUP Cloud with GitHub or another source code repository is as easy as possible! Not ready to spend more than 10 minutes on this operation? Perfect! Our offer is just for you. Do not miss the chance to try it absolutely for free right now!

b152-team.jpg
Customer story

We handle incoming requests faster and can track all activities. Your tool helped us when we scaled. It was smooth and natural.

— Sergey Muslaev, PM