jyrkiput / Hudson-Gerrit-Plugin

http://wiki.hudson-ci.org/display/HUDSON/Gerrit+Plugin
3 stars 8 forks source link

Builds fail with invalid id #2

Closed macbutch closed 14 years ago

macbutch commented 14 years ago

I'm trying to use the Gerrit Hudson plugin with our project. We use Git and Hudson already and the Gerrit plugin seems to be an excellent addition to what we do (currently checking out changes and trying to build them manually). We've followed the instructions over here http://wiki.hudson-ci.org/display/HUDSON/Gerrit+Plugin

It kind of almost works. The connectivity is fine - it is able to clone the repository etc and posts comments back to Gerrit but all the builds fail. We get this output (I've removed our company name from the output):

Started by user mbutcher Checkout:workspace / c:\hudson\jobs\company-native-all-verify\workspace - hudson.remoting.LocalChannel@10ace8d Using strategy: Gerrit Checkout:workspace / c:\hudson\jobs\company-native-all-verify\workspace - hudson.remoting.LocalChannel@10ace8d GitAPI created Fetching changes from the remote Git repository Fetching upstream changes from ssh://hudson@dev.company.com:29418/code/native [workspace] $ c:/cygwin/bin/git.exe fetch -t ssh://hudson@dev.company.com:29418/code/native +refs/changes/:refs/remotes/origin/ [workspace] $ c:/cygwin/bin/git.exe ls-tree HEAD [workspace] $ c:/cygwin/bin/git.exe log --all --pretty=format:'%H#%ct' FATAL: Invalid id: 99226a05862ba49fdb758a47baf1e9d96c6b02f java.lang.IllegalArgumentException: Invalid id: 99226a05862ba49fdb758a47baf1e9d96c6b02f at org.spearce.jgit.lib.ObjectId.fromString(ObjectId.java:230) at hudson.plugins.git.util.GerritBuildChooser.parseCommit(GerritBuildChooser.java:108) at hudson.plugins.git.util.GerritBuildChooser.sortRevList(GerritBuildChooser.java:95) at hudson.plugins.git.util.GerritBuildChooser.getCandidateRevisions(GerritBuildChooser.java:51) at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:604) at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:535) at hudson.FilePath.act(FilePath.java:753) at hudson.FilePath.act(FilePath.java:735) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:535) at hudson.model.AbstractProject.checkout(AbstractProject.java:1044) at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:479) at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:411) at hudson.model.Run.run(Run.java:1253) at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:306) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:127)

I can understand why it is failing - to a degree - because 99226a05862ba49fdb758a47baf1e9d96c6b02f is not a valid Gerrit change Id. It should be e99226a05862ba49fdb758a47baf1e9d96c6b02f (leading e). Also interesting is that when the build fails Hudson adds a comment to the Gerrit change saying that the build failed but it is to a different commit than the one that it fails to retrieve (i.e. I72030c6a4ea67913e26c1050de4ee8cfe0ab3d38 instead of Ie99226a05862ba49fdb758a47baf1e9d96c6b02f ).

Any ideas on what we can do?

-mark

jyrkiput commented 14 years ago

Hi,

I've never tried to run this on Windows, but I'll try it tomorrow and check if there's anything to do. I have some idea what is happening and it should be pretty straightforward to fix. On *nix -environments, there's ' -marks in the beginning of each log output line (ie. 'e99226a05862ba49fdb758a47baf1e9d96c6b02f) and it might be that they are missing on Windows (e99226a05862ba49fdb758a47baf1e9d96c6b02f).

As for the other issue, it's happening because the git plugin fails before it actually does the checkout and gerrit plugin just checks which revision is currently checked out and adds comments to that revision.

macbutch commented 14 years ago

OK, great. Thanks for the quick response too! If theres anything we can do on our side to help out let me know.

-mark

jyrkiput commented 14 years ago

I just pushed a experimental fix into github. It's an educated guess at most (no way to test it right now), but if you could try that out it would help a lot :)

jyrkiput commented 14 years ago

Yep, I just validated this and I'll release a new version today.

macbutch commented 14 years ago

Thank you! I ran out of time to do the test myself today I should be able to look at it tomorrow morning.

macbutch commented 14 years ago

Assuming you're in Finland then I think tomorrow morning for me is this afternoon for you. :)

Thanks again.

jyrkiput commented 14 years ago

Yep, I'm from Finland :) I released a new version, but you must choose different buildchooser (Gerrit-Plugin).

macbutch commented 14 years ago

OK - I can confirm that it is working now.

Thanks for your help on this. This is going to save me a lot of time... :)