
We continue to finish Redmine to fit our needs.
At different times, for several large (and not only) clients, upon request, separate redmine instances were installed.
They are mainly used for personal needs of the client: management of code repositories, internal tasks.
But also in these trackers tasks were set for the system administrator, that is, for us.
Projects grew in their volume and quantity, and the critical moment came when it became difficult to track several trackers at once. At the same time, it is convenient for the client to use his tracker, and to go to ours to set the task of administering is lazy, and simply wasting time.
In view of this situation, we decided to write a plug-in for redmine by our ruby ​​developer kanfet that would collect tasks from all trackers into ours.
Under the cat described the installation and operation of the plugin.
')
Install and configure the plugin
Installation is typical.
Clone the plugin with github:
git clone https://github.com/olemskoi/redmine_synchrony.git /opt/redmine/plugins/redmine_synchrony
and start the migration:
bundle exec rake redmine:plugins:migrate RAILS_ENV="production"
Restart Redmine.
Next, we carry out the configuration: go through the following menu items - “Administration” - “Modules”.
There we see our plugin in the list:

Select "Options".
We press

Get the list of fields to fill:

What is what:
- The address of the site for synchronization is the url of the remote Redmine, from which you need to pull information
- API key - user api key, under which authorization from our Redmine to the remote will occur. The user must have at least read rights to the project.
- Tracker for synchronization - the name of the tracker on the remote Redmine. From this terker will get information about the tasks. To synchronize tasks, they need to be installed in this tracker on a remote Redmine.
- Local project for tasks - the name of the project in our Redmine. Tasks will be created / updated from the remote tracker.
- Local tracker for tasks - the name of the local tracker.
- The language for creating comments is the comment language.
After filling in the changes we save.
You can add as many trackers as you like.
There are the following restrictions:
- Project IDs in the local Redmine should not intersect. That is, only one remote project can be synchronized into one local project.
- The scheme works for Redmine versions from 2.2.x and higher.
To work we need a task in cron, which will initiate the update.
In our particular case, the task is as follows:
*/05 * * * * redmine cd /opt/redmine && PATH=/usr/local/bin:$PATH /usr/bin/bundle exec rake -f /opt/redmine/Rakefile redmine_synchrony:issues RAILS_ENV="production" >/dev/null 2>&1
In case the plugin settings are incorrect, this task will fall out with an error. Therefore, at the stage of switching on and debugging, it is better to include the output of the command in the log file.
Principle of operation
The plugin works according to the following scheme: synchronization is started according to the cron-task.
Our local Redmine passes through the API to the remote and watches the changes of tasks in the tracker specified in the “Tracker for synchronization” settings field.
Changes are tracked for the last day.
In the case of creating a new task in a remote Redmine, it is created in the local one with the full text of the task and with reference to the original one.
When updating a task on a remote Redmine on a local, a comment is created in the corresponding task. The comment text indicates the change in the status of the task, the user who updated it, the priority, if it was changed, and the text of the comment in the original task.
The statuses, priorities and user are written in comments in the text for the simple reason that the values ​​of these parameters on the local and remote redmine do not match.
I have it all.
I will be glad to advice and wishes.
Based on them we will make the necessary improvements.
Thanks for attention!