Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't get automated release working with Hudson + Git + Maven Release Plugin

As the title says, I'm trying to get an automated release job working on Hudson. It's a Maven project, and all the code is in Git. Manually, I do the release on my personal machine like so:

git checkout master
mvn -B release:prepare release:perform

This works perfectly. The Maven release plugin properly pushes the release tag to the origin repository as well as the next commit that bumps the version to the next SNAPSHOT.

However, when I run this same Maven job through Hudson (either by creating my own "release" job or by using the M2 Release Plugin) it doesn't work so well. The release tag gets pushed out to the origin repository, and the release gets pushed out to our Nexus repository, but the subsequent commit that bumps the version to the next SNAPSHOT doesn't go out. Furthermore, the "master" branch in the origin repository doesn't get changed at all. I've looked in Hudson's workspace for the job, however, and the version has been updated.

After looking at the output from the Hudson job, it appears that the Git plugin does not actually checkout "master", but rather it's SHA1 id. That is, if the "master" branch label points to commit "f6af76f541f1a1719e9835cdb46a183095af6861", Hudson does

git checkout -f f6af76f541f1a1719e9835cdb46a183095af6861

instead of

git checkout -f master

As a result, the changes that the Maven release plugin is making are not actually on any branch (certainly not on "master") and these changes don't make it to the origin repository. It runs on the right code, but bookkeeping-wise, the changes seem to get lost because no branch label points to them.

Has anybody gotten the Hudson + Git + Maven Release Plugin combo to work properly? Is there some additional configuration somewhere I can set to make this happen? Or is this a bug in the Hudson Git plugin?

Thanks in advance.

like image 617
Christopher Maier Avatar asked Dec 09 '09 21:12

Christopher Maier


1 Answers

Edited to eliminate out of date info.

See this answer for the current (non-hacky) solution.

like image 175
cemerick Avatar answered Nov 04 '22 11:11

cemerick