简体   繁体   中英

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.

This question has the same issue, but for Bamboo rather than Jenkins. The solution was to delete a file in Bamboo that caches the Git configuration:

<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.

[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. :^)

Note that, as commented below, in the Jenkins script console you can run:
println('git-'+hudson.Util.getDigestOf('remote')) where remote is the the URL of the git remote, to identify the correct cache.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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