2014-11-27 21:48:29 +01:00
redmine_git_remote
==================
2014-11-13 22:16:30 +01:00
2014-11-27 21:48:29 +01:00
Redmine plugin to automatically clone and remote git repositories.
2014-11-18 20:02:29 +01:00
## Installation
2014-11-14 22:17:52 +01:00
2014-11-27 21:48:29 +01:00
Install the plugin as usual:
2014-11-14 22:17:52 +01:00
```
2014-11-27 21:48:29 +01:00
cd REDMINE_ROOT/plugins
git clone https://github.com/dergachev/redmine_git_remote
2014-11-14 22:17:52 +01:00
```
2014-11-28 22:35:33 +01:00
Then enable the new GitRemote SCM type in [http://redmine-root/settings?tab=repositories ](http://redmine-root/settings?tab=repositories )
2014-11-27 22:07:35 +01:00
![](https://dl.dropbox.com/u/29440342/screenshots/AYKNZDTB-2014.11.27-15-59-06.png)
2014-12-03 23:16:12 +01:00
## Supporting private repos
For security sake, we don't support cloning over HTTPS with username password, but only via SSH.
For example:
* This private repo will fail to clone: `https://github.com/dergachev/my-secret-repo`
* Instead, use the SSH form: `git@github.com:evolvingweb/my-secret-repo.git`
If you're going to use the SSH form, you'll need to install the appropriate SSH
keys to `~/.ssh/id_rsa` (in the home directory of your redmine webserver user,
likely www-data).
Some extra tips:
* For GitHub/GitLab, we have found it too troublesome to install repository-specific SSH keys.
Instead we ended up creating recommend creating a
[dedicated account for redmine ](https://developer.github.com/guides/managing-deploy-keys/#machine-users )
and installing the keys there.
* On Ubuntu, the `www-data` user's $HOME is `/var/www` , and by default it's owned by root.
2014-12-03 23:18:59 +01:00
That means you might have to do this before installing Redmine: `sudo mkdir /var/www/.ssh; sudo chown www-data:www-data /var/www/.ssh`
2014-11-18 20:02:29 +01:00
## Usage
2014-11-14 22:17:52 +01:00
2014-11-27 22:07:35 +01:00
This plugin defines a new repository type, GitRemote, which allows you to associate
2014-11-27 21:48:29 +01:00
a remote repository with your Redmine project. First create a new repository of type
2014-11-27 22:07:35 +01:00
GitRemote, enter the clone URL. The identifier and path will be auto-generated, but can be overriden.
2014-11-14 22:17:52 +01:00
2014-11-27 21:48:29 +01:00
![](https://dl.dropbox.com/u/29440342/screenshots/ATIAQXHG-2014.11.27-15-03-51.png)
2014-11-14 22:17:52 +01:00
2014-11-27 21:48:29 +01:00
On submitting the repository creation form, the identifier and `url`
2014-11-28 22:35:33 +01:00
(filesystem path) fields will be auto-generated (if not explicitly provided).
2014-11-14 22:17:52 +01:00
2014-11-28 22:35:33 +01:00
For example, if you enter `https://github.com/dergachev/vagrant-vbox-snapshot` as the Clone URL,
it will prefill the Identifier and filesystem path fields as follows:
2014-11-27 21:49:36 +01:00
* Identifier: `vagrant-vbox-snapshot`
2014-11-28 23:11:35 +01:00
* Path: `REDMINE_PLUGINS_PATH/redmine_git_remote/repos/github.com/dergachev/vagrant-vbox-snapshot`
2014-11-27 21:48:29 +01:00
2014-11-28 22:35:33 +01:00
Once the remote URL is validated, the plugin creates an [empty clone ](http://stackoverflow.com/questions/895819/whats-the-most-straightforward-way-to-clone-an-empty-bare-git-repository ) at the specified path.
2014-11-27 21:48:29 +01:00
This plugin hooks into the core `Repository.fetch_changesets` to automatically
2014-11-28 22:35:33 +01:00
run `git fetch --all` on all GitRemote managed repositories as Redmine is about
to pull in changesets from the local repos.
2014-11-27 21:49:36 +01:00
To avoid slowing down the GUI, we recommend unchecking the "Fetch commits
automatically" setting at
2014-11-27 21:48:29 +01:00
[http://redmine-root/settings?tab=repositories ](http://redmine-root/settings?tab=repositories )
and relying on the following cron job as per [Redmine Wiki Instructions ](http://www.redmine.org/projects/redmine/wiki/RedmineRepositories ):
2014-11-14 22:17:52 +01:00
```
2014-11-27 22:07:35 +01:00
*/5 * * * * cd /home/redmine/redmine && ./script/rails runner \"Repository.fetch_changesets\" -e production >> log/cron_rake.log 2>& 1
```
To trigger fetch manually, run this:
```
cd /home/redmine/redmine & & ./script/rails runner "Repository.fetch_changesets" -e production
2014-11-14 22:17:52 +01:00
```
2014-12-03 23:16:12 +01:00
Notes:
2014-11-27 21:48:29 +01:00
2014-12-03 23:16:12 +01:00
* Tested on Redmine 2.6.
* Currently alpha level, use at your own risk.
* Currently insecure, only install if all redmine project admins are trusted.
* This plugin doesn't clean-up (delete) cloned repos from the file system when the record is deleted from Redmine.