I recently started using Redmine</a> to keep track of my freelance projects. I've found it to fit most of my needs. For the price — free — you can't complain about anything. Some handy features include issue tracking, time tracking, wiki, file storage & upload (intended for software "packages"), and repository integration. This tutorial focuses on the repo integration feature.
Let's assume that you're a progressive developer and have taken to using a "social coding" platform such as GitHub</a> for git or BitBucket</a> for Mercurial. I happen to use both. I prefer Mercurial over git, but you are welcome to your own opinions. Since you keep your code in the cloud</em> and not on your own private server, then you'll need to integrate Redmine into that remote repository. I prefer to use private key encryption since the types of projects I use Redmine for are not public code bases. I also want to back up</em> my repository on my own server. So that now I've got it in three places; BitBucket, my server, and my dev machine.
I probably went about this the wrong way, but I'll share how I did it anyway.
First I set up my private & public keys on my server to be authorized to pull from BitBucket. Then I cloned the repo to a local private dir on my server. Then I updated Redmine's settings to point to that local dir for the hg repository.
Now that I've done my initial clone and set up the repository in Redmine I need to keep the local copy up to date. So I set up a cron job to run every hour. The code is below. (with generic directories inserted)
# Update the local repository for use with Redmine
command expanded for readability, remove line breaks
@hourly cd ~/projects/repo-name; hg pull -u; cd ~/path/to/redmine/; ruby script/runner "Repository.fetch_changesets" -e production</code></pre>
The cron job above does four things; each separated by semicolons. (;) First, it changes the current working directory to the one in which my repo resides. Then, it pulls the latest changesets from the remote repository and updates the local files. Then it changes the current working directory to the one in which Redmine's code resides. Finally it runs the Redmine routine to update it's repository database.
After reading up on the Redmine docs regarding this procedure, it seems that it may only be necessary to call the "Repository.fetch_changesets" as it likely does a pull and update as part of it's routine. I'll check up on that when I'm less busy. For now, my solution works and I'm happy with it.
The reason for the last two bits is that the RSS feed for the project will become stale if Redmine's database isn't updated. Unfortunately that doesn't happen by default unless someone visits the "Repository" tab in Redmine. It is also helpful to improve response time within the Repository tab. By doing the refresh on the hour you can avoid doing it every time the Repository tab is requested. You should turn that off</a> after implementing this cron job. As of Redmine 0.9.x you could also request a web page to perform the repository update action. That code is:
Note</strong>: you could also use curl if you'd prefer.</em>
If you have any questions about this tutorial, please ask them in the comments.