最近遇到的问题,当代码发版后,我在稳定分支上打了一个tag(比如tag名为v_tag_1.0.0),然而过了几天后,产品告知有一个UI显示的问题,迅速改了后,准备再打一个tag,考虑到新的包并没有改版本号,就想着先删除本地和远端的tag(v_tag_1.0.0),然后重新打一个名字相同的tag。打完后,没发现有什么问题,但几天后有组内同学说jekins打包报错了:
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from http://git.iqdnet.cn/qding-hk-app/hkApp.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:888)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1155)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1186)
at hudson.scm.SCM.checkout(SCM.java:504)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
at hudson.model.Run.execute(Run.java:1815)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress http://git.iqdnet.cn/qding-hk-app/hkApp.git
原因:虽然我本地和远端删除了旧的tag,但其他同学本地依然后旧的tag,如果其他同学有tag提交操作,将本地的旧tag提交上去后,就有两个tag名相同的tag记录,这时候jekins拉去tag时就报错了。
解决办法:先删除远端有问题的tag,然后组内各个小伙伴,在本地依次执行以下两条命令
git tag -l | xargs git tag -d #删除所有本地分支
git fetch origin --prune #从远程拉取所有信息
附加tag常用命令:
git tag #列出所有tag
git tag -l v1.* #列出符合条件的tag(筛选作用)
git tag -a -m ‘first version’ #创建含标注tag
git tag -a f1bb97a(commit id) #为之前提交打tag
git push origin --tags #推送所有本地tag到远程
git push origin tag名 #推送指定本地tag到远程
git tag -d tag名 #删除本地指定tag
git push origin :refs/tags/ #删除远程指定tag
git fetch origin #拉取远程指定tag
git show #显示指定tag详细信息