The project management system Redmine + Mercurial on Ubuntu 16.04

as you increase the number of involved people there is a need to more effectively organize and manage their activities. At the initial stage, for this purpose, use Google tables, but their options are limited, and there was a desire to move to a new level. A study of the available project management systems showed that systems with open source Redmine most advanced and some indicators ahead of even proprietary systems.

Redmine has a great potential: managing multiple projects, bug tracking, integration with repositories, cross-references to fixed bugs in commits and to commits in a bug report, assign different user roles in each project, etc., However the installation procedure is quite complicated, and for some very useful features require little modification or use of plugins. I hope that the following guide will help those who wish to use Redmine in your projects.

the

Components


the

the project management System Redmine


Official website

Key features:

the
    the
  • multiple projects
  • the
  • system event tracking (bug, feature)
  • the
  • different user roles (Manager, developer, reporter) for each project
  • the
  • support news, documents, files, wiki, forums for each project
  • the
  • integration with version control systems (SVN, Git, Mercurial)
  • the
  • event notifications via email
  • the
  • the possibility of accounting for working time

the

version control System Mercurial


Official website

Cross-platform distributed version control system.

the

Also need


The Web server and the database management system. Use Mysql and Apache.

the

Installation


Instruction is based on useful, but very outdated instructions
HowTo Install Redmine 1.2.x with Mercurial and Subversion on Ubuntu Server 10.04.

Also used the official installation instructions
Redmine Installation Guide.

Assume that we already have a server pre-installed on it Ubuntu Server 16.04. Instructions describe the installation of the control system and auxiliary SOFTWARE.

So, let's begin. First install LAMP server

the
$ sudo tasksel install lamp-server

During installation, you will need to enter the password root-MySQL database user (not to be confused with the root password of the operating system).

Create MySQL database and user redmine to work with it. Instead of [password] insert the desired user's password.

the
$ mysql-u root-p
(input the root password of the MySQL database)
> create database redmine character set utf8;
> create user 'redmine'@'localhost' identified by '[password]';
> grant all privileges on redmine.* to 'redmine'@'localhost';
> exit

Download Redmine on page www.redmine.org/projects/redmine/wiki/Download or the command

the
$ wget http://www.redmine.org/releases/redmine-3.3.3.tar.gz

Extract Redmine in /usr/share/redmine. Find the subdirectory config and copy config/database.yml.example to config/database.yml. Then edit the file to set the "production" mode of the database:

the
$ sudo cp /usr/share/redmine/config/database.yml.example /usr/share/redmine/config/database.yml
$ sudo nano /usr/share/redmine/config/database.yml

Enter the text and save the file (ctrl+x):

the
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: "[password]"
encoding: utf8

Install the required packages:

the
$ sudo apt install ruby ruby-dev build-essential libmysqlclient-dev

Install Bundler:

the
$ gem install bundler

You can now install gems needed to Redmine:

the
$ cd /usr/share/redmine
$ bundle install --without development test rmagick

Create a random key that Rails uses to encrypt the data in the cookie:
the
$ cd /usr/share/redmine
$ bundle exec rake generate_secret_token

Next create the database structure (execute in /usr/share/redmine):

the
$ RAILS_ENV=production bundle exec rake db:migrate
$ RAILS_ENV=production bundle exec rake redmine:load_default_data

Set the required privileges:

the
$ cd /usr/share/redmine
$ sudo chown-R www-data:www-data files log tmp public/plugin_assets
$ sudo chmod-R 755 files log tmp public/plugin_assets

If you want you can test the Redmine installation by using the web server, WEBrick:

the
$ sudo -u www-data bundle exec rails server webrick -e production

After starting WEBrick Redmine start page should be accessible in a browser at http://localhost:3000/

the

Integration with Apache


Install Passenger:

the
$ sudo apt-get install libapache2-mod-passenger

Add a symbolic link to the Redmine public directory:

the
$ sudo ln-s /usr/share/redmine/public /var/www/redmine

You must configure user Passenger the default for this edit the file:

the
$ sudo nano /etc/apache2/mods-available/passenger.conf

You need to add the following line and save (ctrl+x):

the
PassengerDefaultUser www-data

In the end the file should look like this:

the
<IfModule mod_passenger.c>
PassengerRoot /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
PassengerDefaultRuby /usr/bin/ruby
PassengerDefaultUser www-data
</IfModule>

Next, create a configuration file redmine.conf for apache:

the
$ sudo nano /etc/apache2/sites-available/redmine.conf 

Add the following text and save (ctrl+x):

the
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
ServerName myservername

RewriteEngine on
RewriteRule ^/$ /redmine [R]

<Directory /var/www/redmine>
RailsBaseURI /redmine
PassengerResolveSymlinksInDocumentroot on
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined
</VirtualHost>

Connect modules Passenger and Rewite:

the
$ sudo a2enmod passenger
$ sudo a2enmod rewrite

Disable default web site and connect to redmine:

the
$ sudo a2dissite 000-default
$ sudo a2ensite redmine

Set permissions on the /tmp/cache Redmine:

the
sudo chmod 777 /usr/share/redmine/tmp/cache

Restart Apache:

the
$ sudo service apache2 reload

You can now open your favorite browser and go to http://[my site or ip]/redmine or just http://[my site or ip]. Should appear on the starting page of the system Redmine.

the

Installing Mercurial


You need to install the packages:

the
$ sudo apt-get install mercurial libapache2-mod-perl2 libapache-dbi-perl libdbd-mysql-perl

To create the directory in which to store the repository projects:

the
$ sudo mkdir -p /var/hg/

Now we want to make the repository accessible by http Protocol. For this you need to create the cgi script:

the
$ sudo nano /var/hg/hgwebdir.cgi

Add the following text and save:

the
#!/usr/bin/python
from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb.hgwebdir_mod import hgwebdir
import mercurial.hgweb.wsgicgi as wsgicgi
application = hgwebdir('hgweb.config')
wsgicgi.launch(application)

Now we need to create a file hgweb.config:

the
$ sudo nano /var/hg/hgweb.config

Add the following content and save:

the
[paths]
/=/var/hg/**
[web]
allow_push for = *
push_ssl = false
allowbz2 = yes
allowgz = yes
allowzip = yes

Set file permissions:

the
$ sudo chown-R www-data:www-data /var/hg/*
$ sudo chmod gu+x /var/hg/hgwebdir.cgi

Now we need to create conf file for Apache:

the
$ sudo nano /etc/apache2/conf-available/hg.conf

Add the following content and save:

the
PerlLoadModule Apache2::Redmine
ScriptAliasMatch ^/hg/(.*) /var/hg/hgwebdir.cgi/$1

<Directory /var/hg>
Options +ExecCGI
</Directory>

<Location /hg>
AuthType Basic
AuthName "Mercurial" 
Require valid-user
AuthUserFile /dev/null

#Redmine auth
PerlAccessHandler Apache::Authn::Redmine::access_handler
PerlAuthenHandler Apache::Authn::Redmine::authen_handler
RedmineDSN "DBI:mysql:database=redmine;host=127.0.0.1" 
RedmineDbUser "redmine" 
RedmineDbPass "[password]" 
</Location>

Still need to create the link:

the
$ sudo ln-s /etc/apache2/conf-available/hg.conf /etc/apache2/conf-enabled/
$ sudo ln-s /usr/share/redmine/extra/svn/Redmine.pm /usr/lib/x86_64-linux-gnu/perl5/5.22/Apache2/

Enable CGI module and restart Apache:
the
$ sudo a2enmod cgi
$ sudo service apache2 reload

The repository will be available at http://[my site or ip]/hg/*. For example, for the project address will be http://[my site or ip]/hg/project. If the project is a subproject subproject1, then its repository is available at http://[my site or ip]/hg/project/subproject1.

To clone the repository will need to perform:

the
$ hg clone http://[my site or ip]/hg/project

If the cloned project is not public (set in the project settings through the web interface of the system Redmine), you will need to enter a user name and password.

The authorization is based on projects, i.e. access is only possible for project participants (managers and developers).

When you create a repository in the web interface of Redmine, you need to specify the path to it, e.g. /var/hg/projectname. Repository in /var/hg must be created manually for each project and initialize command (hg init).

After creating a new repository we need to make sure it has the correct permissions:

the
$ sudo chown-R www-data:www-data /var/hg/[repository name]

In principle, it is possible to automate the creation of repositories. Information about this in the guide at the link HowTo Install Redmine 1.2.x with Mercurial and Subversion on Ubuntu Server 10.04

the

Notifications commit the changes by email


Redmine supports notifications about various events (changes in the life of a bug/feature, etc.). In order to use this functionality, it is sufficient to configure the method of sending email messages. This is done in the file /usr/share/redmine/config/configuration.yml file there are templates for different configurations. You need to raskomentiruyte and edit.

For example:

the
 email_delivery:
delivery_method: :smtp
smtp_settings:
address: "10.11.12.13"
port: 25
authentification: none
enable_starttls_auto: false
openssl_verify_mode: 'none'

Please note that each section in the configuration file.yml moved two spaces. This is important.

Basic information should be available after you specify how to send emails. However, for notifications about changes to the repository, you must use an external plugin. You can download it from the site github.com/lpirl/redmine_diff_email.

Install this plugin. To do this, copy the content of plugin into /usr/share/redmine/plugins/redmine_diff_email. In accordance with the instructions for installing the plugin change the file /usr/share/redmine/app/views/repositories/_form.html.erb:

the
--- OLD
+++ NEW
@@ -23,6 +23,7 @@
<% button_disabled = ! @repository.class.scm_available %>
<%= repository_field_tags(f, @repository) %>
<% end %>
+<%= call_hook(:view_repository_form) %>
</div>
<p>

The original plugin works with an outdated version of redmine. For redmine-3.3 need to make changes to a file
/usr/share/redmine/plugins/redmine_diff_email/db/migrate/002_add_repositories_is_diff_email_attached.rb. The contents of the file should be:

the
class AddRepositoriesIsDiffEmailAttached < ActiveRecord::Migration
def self.up
add_column :repositories, :is_diff_email_attached, :boolean, :default => false, :null => false
Repository.update_all(["is_diff_email_attached = ?", true])
Repository.update_all(["is_diff_email = ?", true])
end

def self.down
remove_column :repositories, :is_diff_email_attached
end
end

Then in /usr/share/redmine to run a command to update the database:

the
bundle exec rake redmine:plugins:migrate RAILS_ENV=production

Restart Redmine:

the
$ sudo service apache2 reload

If the plugin is installed correctly in the plugins list Administration → Plugins appears Redmine Diff Email Plugin, as well as in the web interface Redmine SomeProject → "Settings" Tab → "Repositories" Tab → "Edit" appear in the notification settings.

In addition to information about changes in the repository automatically tracked in Redmine, you must perform additional steps. First you need to enable WS for repository management and generate API key. How this is done:

* In the web interface in Redmine Administration menu select Settings
* Go to the Repositories tab
* Enable the 'Enable WS for repository management'
* Click on 'Generate a key'

Next, create the script:

the
$ sudo nano /var/hg/fetch_changes

Add the following text and save: (you must replace [your API key] generated API key)

the
#!/bin/sh
curl "http://localhost/redmine/sys/fetch_changesets?key=[your API key]" > /dev/null 2>&1

Set access permissions for the created file:

the
$ sudo chown www-data:www-data /var/hg/fetch_changes
$ sudo chmod ug+x /var/hg/fetch_changes

It is necessary to add in /var/hg/hgweb.config section [hooks] to fetch_changes script was run after each commit:

the
[hooks]
changegroup = /var/hg/fetch_changes

Now with changes in the repository, Redmine will automatically send notifications to the participants of the project.
Article based on information from habrahabr.ru

Комментарии

Популярные сообщения из этого блога

Integration of PostgreSQL with MS SQL Server for those who want faster and deeper

Custom database queries in MODx Revolution

Google Web Mercator: a mixed coordinate system