简体   繁体   English

从 Jenkins 中删除 git 缓存

[英]Remove git cache from Jenkins

I'm trying to create a release from Maven, but I'm getting a git tag already exists error, even though I have deleted that tag from both my local machine and the remote repository.我正在尝试从 Maven 创建一个版本,但我收到一个git tag already exists错误,即使我已经从本地机器和远程存储库中删除了该标签。

This question has the same issue, but for Bamboo rather than Jenkins. 这个问题有同样的问题,但对于 Bamboo 而不是 Jenkins。 The solution was to delete a file in Bamboo that caches the Git configuration: 解决方案是删除 Bamboo 中缓存 Git 配置的文件:

<BAMBOO_HOME>/xml-data/build-dir/_git-repositories-cache

How can I do the same thing with Jenkins?我怎样才能对詹金斯做同样的事情?

Ran into the same thing today, found the git repository cached on my master at /var/lib/jenkins/caches if you have lots of git repos you will need to try and find your specific one since they are listed by hashes and not by name.今天/var/lib/jenkins/caches了同样的事情,在/var/lib/jenkins/caches找到缓存在我的 master 上的 git 存储库,如果您有很多 git 存储库,您将需要尝试找到您的特定存储库,因为它们是按哈希列出的,而不是按姓名。

[jenkins@jenkinsmaster caches]$ pwd
/var/lib/jenkins/caches
[jenkins@jenkinsmaster caches]$ ls -als
...
4 drwxr-xr-x.  3 jenkins jenkins 4096 Nov  8 09:10 git-bbcfdeb24494d83c13621c40b3b14ffd
4 drwxr-xr-x.  2 jenkins jenkins 4096 Nov  8 09:10 git-bbcfdeb24494d83c13621c40b3b14ffd@tmp
...

Once I found the correct one ( by going into each and running a git tag -l looking for my unwanted tags. I just deleted the git-<hash> and git-<hash>@tmp folders from that directory. Re-ran my Job and the source was fully checked out again and did not have the unwanted tags. :^)一旦我找到了正确的(通过进入每个并运行git tag -l寻找我不需要的标签。我刚刚从该目录中删除了git-<hash>git-<hash>@tmp文件夹。重新运行我的工作和来源再次完全检出,没有不需要的标签。:^)

Note that, as commented below, in the Jenkins script console you can run:请注意,如下所述,您可以在 Jenkins 脚本控制台中运行:
println('git-'+hudson.Util.getDigestOf('remote')) where remote is the the URL of the git remote, to identify the correct cache. println('git-'+hudson.Util.getDigestOf('remote'))其中remote是 git remote 的 URL,以识别正确的缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM