There are many similar topics (many of them very old) but I am still lost. I have two servers, one has gitolite setup, and another has redmine setup. User is pushing changes to the repository created on gitolite server. Redmine is a user on this gitolite server and is pulling changes from it and showing them in browser.
More precisely, I have used the following line on redmine server:
git clone --mirror ssh://gitolite3@gitoliteserver/testing
Then, I configured this repository (testing.git) as a known repository to redmine - redmine can use bare and local repositories, only.
When user push changes to gitolite server, redmine does not automatically show them. I have to do the following on redmine server:
cd testing.git
git remote update
I could use cron on redmine server for regular updating repository testing.git. But many says this is inefficient and propose hooks. However, information are very confusing. Can you help me by answering if cron is a viable solution and if "git remote update" is a correct command for this cron? Or give me a clean example how to use hooks for my problem.
Not directly connected to the question, but I have to say. For me, non-native english, words as miror, mirrored, mirroring, etc. are hard to follow, please use alice and bob and such more easy terms. Even the word remote is confusing, if I am on A then B is remote for me, but if I am on B then A is remote for me. Thus, it is hard to read about git on the net, and the things are further complicated by the facts, that some solutions are github or bitbucket only variants.
The first way that I would choose is to use Redmine + Gitolite integration via dedicated plugin, as explained here:
http://redmine-git-hosting.io/
Second way, is what you have attempted, so:
Pulling the changes via cron job or some other kind of scheduled task is legit thing to do, however then some delay exists between commit and a cron job, and also unnecessary utilization of resources like networking and cpu for testing repository even if there is no change...
In order to properly utilize given resources, a recommended way are hooks, in both Redmine and git server.
So on your gitolite, you need to have post-receive hook, which would perform:
So for example, a git's post-receive hook would look like:
#!/bin/bash
/usr/bin/sshpass -pPassword ssh -o StrictHostKeyChecking=no user@server 'cd /home/user/repo/ && git pull origin master'
curl "http://<redmine url>/sys/fetch_changesets?key=<your service key>"
Redmine webservice key for updating repositories can be found in Administration | Settings | Repository tab