Maven release fails due to git failure
Solution 1
Just to add to Tobb's excellent original answer..
I noticed that this has been fixed but had issues getting the new version to work..
You have to add it as a plugin (not project) dependency, eg.
<!-- Appengine deploy at end of mvn release:perform -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.2.2</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
</plugin>
Solution 2
Turned out that this was an error that had been encountered before. This is due to a bug in maven-scm-provider-git, which causes the file-reference to a local repository for checkout to lose its ':' in "C:...". (The bug is described here: http://jira.codehaus.org/browse/SCM-662)
We fixed this by copying a fixed version of the jar into the local maven repository, but I had recently cleared my local repository in order to see if our Nexus repo was behaving correctly, and thus got an unfixed version of the jar in my local repo (doh!)
So, added the fixed version of the jar to my local maven repo, the git clone-command contained a ':' again, and things started working :)
Edit: This bug is fixed in version 2.4 of the maven release plugin.
Tobb
Updated on July 18, 2022Comments
-
Tobb almost 2 years
I am trying to do a mvn release, but it fails due to problems with git. I have done this multiple times before without this problem, and I really don't get why/how this is happening.
I first got it doing mvn release:prepare, but got around it by adding the last line shown below to my root-pom:
<artifactId>maven-release-plugin</artifactId> <configuration> <preparationGoals>clean install</preparationGoals> <pushChanges>false</pushChanges>
But now, when I try to do mvn release:perform, I get the error message again:
[INFO] Executing: cmd.exe /X /C "git clone file://C\Users\torbjornk\nfr\MyProject/ C:\Users\torbjornk\nfr\MyProject\target\checkout" [INFO] Working directory: C:\Users\torbjornk\nfr\MyProject\target [ERROR] The git-clone command failed. [INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Unable to checkout from SCM Provider message: The git-clone command failed. Command output: fatal: 'C:/Program Files (x86)/Git' does not appear to be a git repository fatal: The remote end hung up unexpectedly
I do not get where it gets the idea that my git-installation-folder is supposed to be a git repository! The git clone-command logged right before the error is happening does not contain a reference to this folder either..
-
khmarbaise over 11 yearsHow does you scm part in pom look like?
-
Shankar almost 4 yearsHow did you solved this problem? I am also facing more that 10 days.
-
-
Tobb over 11 yearsThe clone command is issued by maven, I do not control it. MyProject is the project root, which actually is a git repository.. I tried running the command (though with a different resulting folder, since it gave a different error), and still get the same error..
-
Ilion over 11 yearsHave you tried running it from the command line to see what happens?
-
Tobb over 11 yearsSee answer above. Strange thing is, when doing mvn release:perform it stopped at git push, but after disabling pushing as part of the mvn plugin, I could still push from the command line..
-
Tobb over 11 yearsIt worked if I just added a ':' after the C, so it's file://C:\... doesn't help much though, as long as maven generates the command without the ':'.
-
Ilion over 11 yearsAccording to owengriffin.com/posts/2010/04/15/… you should have <scm></scm> elements defined in your pom.xml. What are they set to?
-
Tobb over 11 years<scm> <connection>scm:git:file://${basedir}/</connection> </scm>
-
Ilion over 11 yearsSo something seems to be wrong with the ${basedir} expansion. I'm not sure why that would be unfortunately. You could hardcode the path but that would make it less portable.
-
khmarbaise over 11 years${basedir} in a SCM part is not recommened nor does it make sense. You should use a remote repo with Git which can be a file ref like file:///.... but it must be outside of the maven project.
-
Tobb over 11 yearsWhy is it not recommended? The ${basedir} points to the directory containing the root pom.. The last part I don't really get, we do use a remote repository, and how can I have a git repository for a project if the repo is outside the maven project? (Are you saying that what should be cloned to the checkout-folder should be from the remote repo, which is updated by mvn release:prepare?)
-
Tobb over 11 yearsGreat, I'm actually going to build for release later today, I remove the fixed jar from my maven-repo and try this.
-
Tobb over 11 yearsWorks like a charm :) +1 and accepted answer, it's much better than the solution we had, since it doesn't involve any manual steps.
-
Tobb over 11 yearsActually, didn't work that well :s The release:prepare worked, but upon release:perform, it failed. This was due to a quirk in our setup, where we check out from local instead of remote when releasing. But, it got me on the right track, and updating the version of the release plugin to 2.4 ended up doing the trick.
-
Shankar almost 4 yearsHave you guys fixed this? I am looking for solution and which I am using mvn 3.0.8