Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven release:prepare fails to commit tag

Attempting to perform a release on a maven project, which has successfully released before.

When I perform mvn release:prepare I am prompted for the release tags and the new snapshot tags and the project builds.

But when it attempts to push to the remote, I get

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.0:prepare (default-cli) on project NeuralAnalysis: Unable to tag SCM [ERROR] Provider message: [ERROR] The git-push command failed. [ERROR] Command output: [ERROR] To ssh://[email protected]/NeuralAnalysis.git [ERROR] ! [rejected] NeuralAnalysis-1.5.6 -> NeuralAnalysis-1.5.6 (non-fast-forward) [ERROR] error: failed to push some refs to 'ssh://[email protected]/NeuralAnalysis.git' [ERROR] To prevent you from losing history, non-fast-forward updates were rejected

And indeed, attempting to perform git push ssh://[email protected]/NeuralAnalysis.git NeuralAnalysis-1.5.6 manually, also exits with the same complaint.

Performing git pull says 'Already up-to-date'. git branch shows I am on the 'master'. git push origin gives 'Everything up-to-date'.

Looking at the repository using Tower shows that 'master', 'origin/master' and 'NeuralAnalysis-1.5.6' are all the same and on the last commit. The working directory contains release.properties and pom.xml.releaseBackup files.

It looks to me like everything is fine with the repository overall.

like image 805
Peter N. Steinmetz Avatar asked Jun 03 '12 23:06

Peter N. Steinmetz


People also ask

What does mvn release prepare do?

mvn release:prepare This command prepares for a release in SCM. It goes through several phases to ensure the POM is ready to be released and then creates a tag in SVN which can be used by release:perform to make a release.

What is release prepare?

Description: Prepare for a release in SCM. Steps through several phases to ensure the POM is ready to be released and then prepares SCM to eventually contain a tagged version of the release and a record in the local copy of the parameters used. This can be followed by a call to release:perform .

What is SCM release tag?

scm:tag will "only" perform a tag operation on the SCM system, where release:prepare will perform various tasks, included a tag operation on the SCM system. Sometimes you only want to perform the tag operation, without all the other things the release:prepare mojo does.


1 Answers

Turns out it was a remote tag with the same name, as suggested by VonC in the comment. This was likely created by some previously aborted release.

Although I found the remote tag by manually inspecting the refs/tags directory on the remote repository, git ls-remote --tags will show them as well and the git push --verbose will also show more about the problem in general.

To fix this, first retrieve the remote tags with git fetch --tags.

One way to perform the next step is then to simply bypass that release tag by updating the pom.xml to have a higher -SNAPSHOT version (including any references in the same project by other modules to that snapshot), check these in, and do mvn release:clean; mvn release:prepare over again.

like image 133
Peter N. Steinmetz Avatar answered Sep 20 '22 17:09

Peter N. Steinmetz