Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove git cache from Jenkins

Tags:

git

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?

like image 420
octavian Avatar asked Mar 24 '17 17:03

octavian


People also ask

How do I clear my github cache?

The easiest way to clear your Git cache is to use the “git rm” command with the “–cached” option. You can choose to remove one file or to remove an entire working directory.

Does Jenkins have a cache?

Introduction. This plugin provides caching for dependencies and build artefacts to reduce build execution times. This is especially useful for Jenkins setups with ephemeral executors which always start from a clean state, such as container based ones.

What is git caching?

Consider a Git tutorial — as knowing how/what this is, and how it is used, is very important to using Git. The “cache”, in this context, contains staged changes. The contents are stored on disk, in repo's . git folder.


1 Answers

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.

like image 154
Sean Avatar answered Oct 03 '22 01:10

Sean