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.
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.
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 .
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With