|
There is a known bug related to Subversion clients and the Maven Release plugin that can take some time to resolve if you aren't aware of it.
Sometimes, when you run the mvn release:prepare operation, you will get a strange Subversion error saying that a file already exists in the repository. This can be either because the release tag _has_ already been created (usually due to human error, such as messing up the version numbers in the POM files), or because of an obscure Subverion bug. The main symptom of this issue is that Subversion claims that a file (any file) already exists in the Subversion repository:
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Unable to tag SCM
Provider message:
The svn tag command failed.
Command output:
svn: Commit failed (details follow):
svn: File '/repos/test_repo/ci_test_project/tags/ci_test_project-1.5.24/bin/release.sh' already exists
If this occurs, you simply need to run svn update and then mvn release:prepare again.
Now the beauty of the Maven Release Plugin is that you can automate the whole bump-up-the-version-numbers-and-create-a-new-Subversion-tag-and-deploy-to-Nexus business. The obvious next step is to place this task on your trusty CI server. However, if you come across this error, you're stuck, as the build will effectively fail. Even if you use the Maven scm:update goal systematically beforehand, manually or by binding it to a particular lifecycle phase, you still come across the problem.
One simple albeit unelegent work-around is to write a simple script to handle the error, as shown here:
#!/bin/sh
MAVEN=$M2_HOME/bin/mvn
$MAVEN release:prepare --batch-mode
if [ $? -ne 0 ] ; then svn up && $MAVEN release:prepare --batch-mode ; fi
$MAVEN release:perform
If the release:prepare operation fails, then update and try again. If it's a real problem, it will fail again anyway. Otherwise, you're good! A scripting pro could probably do something nicer, but that's the core of it. Simple but functional!
Trackback(0)
 |