Maven Release-plugin "tag already exists" for nonexistant tag
Asked Answered
S

5

14

My setup: git-repository on an Atlassian Stash-server and Atlassian Bamboo. I'm using Maven 3.1.1 with the release-plugin 2.3.2. The plan in Bamboo looks like this:

  1. Check out from git-repository
  2. perform a clean install
  3. perform release:prepare and release:perform with ignoreSnapshots=true and resume=false

Everything up to the last step works fine, but Maven states, that it can't tag the release, because the tag already exists. Here is the log:

build   26-Nov-2013 10:36:37    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.2:prepare (default-cli) on project [PROJECT-NAME]: Unable to tag SCM
build   26-Nov-2013 10:36:37    [ERROR] Provider message:
build   26-Nov-2013 10:36:37    [ERROR] The git-tag command failed.
build   26-Nov-2013 10:36:37    [ERROR] Command output:
build   26-Nov-2013 10:36:37    [ERROR] fatal: tag '[PROJECT-NAME]-6.2.2' already exists

Well, obviously the tag already exists, no big deal. However, this is what git tag looks like for my repository:

bash:~/git/repositories/PROJECT-NAME$ git tag
[PROJECT-NAME]-5.2.5
[PROJECT-NAME]-5.3.0
[PROJECT-NAME]-5.3.1
[PROJECT-NAME]-5.4.0
[PROJECT-NAME]-5.5.0
[PROJECT-NAME]-5.5.1
[PROJECT-NAME]-5.5.2
[PROJECT-NAME]-5.5.3
[PROJECT-NAME]-5.5.4
[PROJECT-NAME]-5.6.0
[PROJECT-NAME]-5.6.1
[PROJECT-NAME]-5.6.2
[PROJECT-NAME]-5.6.3
[PROJECT-NAME]-5.6.4
[PROJECT-NAME]-5.6.5
[PROJECT-NAME]-5.6.6
[PROJECT-NAME]-6.0.0
[PROJECT-NAME]-6.0.1
[PROJECT-NAME]-6.0.2
[PROJECT-NAME]-6.1.0
[PROJECT-NAME]-6.1.1
[PROJECT-NAME]-6.1.2
[PROJECT-NAME]-6.2.0
[PROJECT-NAME]-6.2.1

The git-repository is cloned via svn2git from an svn-repository. I've tried multiple times reimporting the repository and deleting and re-cloning it on the stash-server. Yet the tag 6.2.2 seems to exist somewhere in the depths for Maven. What's going on here?

Update: I just tried removing ALL tags from the repository. Same result. Changing the version from 6.2.2 to 6.2.3 showed positive results.

Another update: It seems to have something to do with the name of the repository. Creating a new repository with the same name but adding -2 at the end helped.

Softball answered 26/11, 2013 at 9:51 Comment(0)
S
2

Shortly after my last discovery which screamed "CACHE PROBLEM!" I found the solution. I deleted all repository-cache-data following the instructions on this site: https://confluence.atlassian.com/display/BAMKB/Git+cache+removal+in+Bamboo

Softball answered 28/11, 2013 at 7:26 Comment(1)
Do you know how to do this if the build tool is Jenkins?Dispatch
R
10

mvn release:clean before release:prepare is what worked for me

Radical answered 31/7, 2019 at 11:35 Comment(1)
I have jenkins job setup and it already has these commands in the script which is supposed to build jars. The build is successful but the job fails with this error none the less.Dempstor
B
5

I experienced this error again and again in a Jenkins release build after a release had failed previously. I restored the repository state before the release and verified that the tag did not exist anymore using git tag. To be absolutely sure, I also deleted the tag locally and remotely using:

git tag --delete mytag
git push --delete origin mytag

Both commands reported that the tag did not exist. Regardless, the release build kept failing with

[ERROR] The git-tag command failed.
[ERROR] Command output:
[ERROR] fatal: tag 'mytag' already exists`.

I finally solved this by enabling the option

Build Environment -> Delete workspace before build starts

Hence the problem is that after a failed release build the Jenkins workspace is left with a dirty repository state in which the tag still exists.

Brocatel answered 19/11, 2019 at 21:14 Comment(0)
S
2

Shortly after my last discovery which screamed "CACHE PROBLEM!" I found the solution. I deleted all repository-cache-data following the instructions on this site: https://confluence.atlassian.com/display/BAMKB/Git+cache+removal+in+Bamboo

Softball answered 28/11, 2013 at 7:26 Comment(1)
Do you know how to do this if the build tool is Jenkins?Dispatch
S
1

Try options "Clean before Build" and "Clean After Build" within Source Code Management -> Additional Behaviors.

Sweaty answered 25/7, 2018 at 18:2 Comment(0)
S
-1

What worked for me was running mvn clean .

Seise answered 20/3, 2015 at 20:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.