git Maven Release-plugin“标签已经存在”用于不存在的标签

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20213557/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:24:02  来源:igfitidea点击:

Maven Release-plugin "tag already exists" for nonexistant tag

gitmavenbamboobitbucket-serversvn2git

提问by Vince

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

我的设置:-servergit上的 -repositoryAtlassian StashAtlassian Bamboo. 我使用的是Maven 3.1.1release-plugin 2.3.2。计划Bamboo如下:

  1. Check out from git-repository
  2. perform a clean install
  3. perform release:prepareand release:performwith ignoreSnapshots=trueand resume=false
  1. git-repository 检出
  2. 执行一个 clean install
  3. 执行release:preparerelease:performignoreSnapshots=trueresume=false

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

到最后一步为止一切正常,但Maven声明它不能标记发布,因为标记已经存在。这是日志:

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 taglooks like for my repository:

好吧,显然标签已经存在,没什么大不了的。但是,这就是git tag我的存储库的样子:

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 svn2gitfrom 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.2seems to exist somewhere in the depths for Maven. What's going on here?

所述git-repository通过克隆svn2gitsvn-repository。我已经多次尝试重新导入存储库并在stash-server上删除和重新克隆它。然而,标签6.2.2似乎存在于Maven. 这里发生了什么?

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

更新:我只是尝试从存储库中删除所有标签。结果一样。将版本从 更改6.2.26.2.3显示出积极的结果。

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 -2at the end helped.

另一个更新:它似乎与存储库的名称有关。创建一个同名的新存储库,但-2在最后添加有帮助。

采纳答案by Vince

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

在我最后一次发现后不久尖叫着“缓存问题!” 我找到了解决方案。我按照本网站上的说明删除了所有存储库缓存数据:https: //confluence.atlassian.com/display/BAMKB/Git+cache+removal+in+Bamboo

回答by Peter Szalay

mvn release:cleanbefore release:prepareis what worked for me

mvn release:clean以前release:prepare对我有用

回答by davehofmann

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:

在之前发布失败后,我在 Jenkins 发布版本中一次又一次地遇到此错误。我在发布之前恢复了存储库状态,并使用git tag. 可以肯定的是,我还使用以下方法在本地和远程删除了标签:

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.

因此,问题是在发布构建失败后,Jenkins 工作区会留下一个脏的存储库状态,其中标签仍然存在。

回答by Vivek Vermani

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

尝试在源代码管理 -> 其他行为中选择“构建前清理”和“构建后清理”选项。

回答by thouliha

What worked for me was running mvn clean.

对我有用的是跑步mvn clean