Project

General

Profile

What's your Git workflow with Redmine?

Added by Matthew Williams over 16 years ago

I'm getting ready to integrate two fairly large Git repositories into Redmine.

I need to access these repositories via ssh and are protected with a username and password. Because I can't point Redmine to ssh://host/.git for my repo but I instead need to do a local clone of it.

Would a recurring task of git pulls every few minutes be the best method of keeping my local repo up to date so Redmine is up to date with the latest commits?

Does this sound like a valid work flow or is there a better methodology to accomplish this?


Replies (17)

RE: What's your Git workflow with Redmine? - Added by Calvin Cheng over 16 years ago

Hi Matthew,

My colleagues and I use git in conjunction with redmine for multiple branch deployment of our projects.

As you said correctly, we need to ensure that there is a cloned "central" (not a very appropriate term to use for a DVCS) repository hosted on the same server where redmine is installed. From our local machines, we push into this "central" repository and a git 'post-update' shell script then pushes out specific branches into other remote git repositories.

Not sure if this workflow can be matched with what you are intending to do but I have found that this is a great set-up for us which gives us total automation in handling deployments.

Regards,
Calvin

RE: What's your Git workflow with Redmine? - Added by Calvin Cheng over 16 years ago

O, and I should mention that all transactions are handled by project specific operating system "user". For each project, we create a user using "adduser" or "useradd" whichever you like and using that user's password, we are able to create ssh transactions between our local machine and the remote "central" repository.

We have taken also an extra step of "cat"-ing our own keys to the server so that the transactions can be passwordless and we do not have to waste time typing in passwords everytime we need to push into the remote server.

RE: What's your Git workflow with Redmine? - Added by Stuart George over 16 years ago

I use gitosis for my git server, and I have a post commit hook on each repo that does a git pull on a local repository, which then runs the ruby script/runner “Repository.fetch_changesets” -e production call.

(gitosis does all my ssh key management for user access too)

RE: What's your Git workflow with Redmine? - Added by Matthew Williams over 16 years ago

Right now I'm simply setting up Redmine for individual Git repositories on a project basis. They're only accessible via ssh so I'm cloning them locally to the server that Redmine is running and then periodically doing a git pull and firing off the scrip/trunner repo fetch script.

I'm thinking about building in a simple controller action into the repository controller for Git users that when called with a POST request, run a Git pull on the repository for that specific project and that could be called with a git post-commit hook. So when a user commits to their local Git repo, Redmine will do a pull to get the latest changes locally and then fire off the runner script to get the data into Redmine.

Should this be a monkey patch on my install or does anyone have any opinions on creating a Redmine issue for this and getting into trunk?

RE: What's your Git workflow with Redmine? - Added by Eric Davis over 16 years ago

Should this be a monkey patch on my install or does anyone have any opinions on creating a Redmine issue for this and getting into trunk?

A patch for the trunk would be good but you could also put that into a Plugin. I don't think it would be that difficult and would let others use it without upgrading to trunk. If you go the plugin route, ping me on Github and I'll try to help.

Eric

RE: What's your Git workflow with Redmine? - Added by Matthew Williams over 16 years ago

A plugin sounds fantastic. I don't know if and when I'll be able to start such a project. So if you want to spin something up on Github that would be great, especially if you have the need and could see others using it.

I think a nice Git tab on a Git enabled project would be good... But what functionality should be there? I think there's a lot that could be added. For starters, executing a pull request. It should also establish an endpoint URL that can be touched that will execute the pull request automatically for use on a post-commit hook.

I think I've seen some Javascript widgets in the past that build some nice branch trees using a Git repo. That might be interesting to have in there. With all of the functionality of Git, a plugin like this could go a pretty long way.

RE: What's your Git workflow with Redmine? - Added by Matthew Williams over 16 years ago

Project created!

http://github.com/mwilliams/redmine-git-extras-plugin

Nothing fancy yet, just displays repo information. I have a small TODO and any ideas are certainly welcomed. Simply issue a pull request if you've got anything good and I'll gladly bring it in.

Eric, thanks for existing plugins, they helped a lot getting this off the ground (even though it hasn't gone far yet). But looking at your Customer plugin was a great help.

RE: What's your Git workflow with Redmine? - Added by Eric Davis over 16 years ago

Project created!

Project forked! We might want to take a look at grit, it's goal is to be a pure Ruby implementation of git. It might eliminate Redmine's requirement of having a git repository checked out.

Eric, thanks for existing plugins, they helped a lot getting this off the ground (even though it hasn't gone far yet). But looking at your Customer plugin was a great help.

Thanks for the compliment. That's the reason why I'm trying to Open Source them as much as possible. If you want to see some advanced stuff, check out my Budget Plugin, specifically the lib/ directory.

I haven't mentioned it yet but I created a Redmine plugin skeleton on Github (http://github.com/edavis10/empty-redmine-plugin/tree/master). It's just the base structure of the sample plugin with empty folders and documentation. I'm using it as a starter for all my plugin development and trying to update as I find missing pieces. I got RSpec working in another plugin that I'm going to port next.

Eric

RE: What's your Git workflow with Redmine? - Added by Peter Fitzgibbons about 16 years ago

HI Eric, Everyone,

Are any of you using a repository on ssh from a project ?

I'm having trouble with getting the repository browsing to work with a git project on ssh at
ssh://host/git/myproject.git

This works :
git clone ssh://pfitzgibbo-2/git/myproject.git
Initialized empty Git repository in ...
.. Resolving deltas: 100% (6/6), done.

This doesn't :
ruby script/runner "Repository.fetch_changesets" -e production
fatal: Not a git repository: 'ssh://pfitzgibbo-2/git/myproject.git/'
fatal: Not a git repository: 'ssh://pfitzgibbo-2/git/myproject.git/'

RE: What's your Git workflow with Redmine? - Added by Eric Davis about 16 years ago

Are any of you using a repository on ssh from a project ?

No, I use the filesystem path (/home/git/checkouts/budget_plugin/.git). I don't think ssh is supported via git, there needs to be a local checkout on the server for Redmine to read from. If you clone the ssh version to a directory and then put that directory into Redmine it should work.

git clone ssh://pfitzgibbo-2/git/myproject.git /my/git/checkouts
(Redmine Repo Settings) Path to .git directory = /my/git/checkouts/.git

Eric

RE: What's your Git workflow with Redmine? - Added by Peter Fitzgibbons about 16 years ago

HI Eric, All,

Can one of you post an example hook in the git repository to automate the git-update-to-local when someone pushes to the repository ?

RE: What's your Git workflow with Redmine? - Added by Eric Davis about 16 years ago

Can one of you post an example hook in the git repository to automate the git-update-to-local when someone pushes to the repository ?

Sure, this is the post-update hook I use. /home/git/checkouts/budget_plugin is where Redmine is setup to read from.

#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, make this file executable by "chmod +x post-update".

exec git-update-server-info

WC='/home/git/checkouts/budget_plugin'

echo "*** Updating Redmine repo..." 
cd $WC || exit
unset GIT_DIR
git pull

Eric

RE: What's your Git workflow with Redmine? - Added by Peter Fitzgibbons about 16 years ago

HI Eric,

I had to debug this script on my end... wondering if you can shed some insight on why...

In my script, 'exec git-update-server-info' caused and exit in the script.. no error (that I can tell), and git push succeeds as expected... but the rest of the script ($WC=.. and on ) does not execute.
I had to put the 'exec git-update-server-info' at the end.

Any idea why ?

Thanks.
Peter

RE: What's your Git workflow with Redmine? - Added by Eric Davis about 16 years ago

Peter Fitzgibbons wrote:

In my script, 'exec git-update-server-info' caused and exit in the script.. no error (that I can tell), and git push succeeds as expected... but the rest of the script ($WC=.. and on ) does not execute.
I had to put the 'exec git-update-server-info' at the end.

I don't know. 'exec git-update-server-info' is used to regenerate some files used by the git web interface. If you are not using it, you can safely remove that line.

Eric

RE: What's your Git workflow with Redmine? - Added by Peter Fitzgibbons about 16 years ago

Ahh, education time for me.

Why would git scripts be calling 'any' git command (even child-scripts of the main hooks, etc) with 'exec' ?
Both bash and sh manfiles say exec replaces the shell... which means the exit of the command is the exit of what-used-to-be the shell process. Huh? so much for error handling.

man bash :
exec [-cl] [-a name] [command [arguments]]
If command is specified, it replaces the shell. No new process is created. The arguments become the arguments to command. [...]

man sh :
exec [command arg ...]
Unless command is omitted, the shell process is replaced with the specified program (which must be a real program, not a shell builtin or function). Any redi‐
rections on the exec command are marked as permanent, so that they are not undone when the exec command finishes.

Should I post this question in a new topic ?

RE: What's your Git workflow with Redmine? - Added by Chris Dew almost 16 years ago

http://finalcog.com/remine-git-post-receive

Should I be using git's post-receive or post-update hook?

RE: What's your Git workflow with Redmine? - Added by Jared Moody almost 16 years ago

I just made a quick hack to run a git fetch on the local repository before redmine fetches changesets:

http://dev.elevationblog.com/2009/1/15/redmine-and-git

    (1-17/17)