Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins disable or clear cache for maven builds

Our maven projects all build on a jenkins and then deploy the artifacts to a maven repository.

For some reason however there seems to be some kind of cache or update lag when building a project that has dependencies to other projects that just got newly build.

Say there's a bug in artifact A and B depends on A. Now I fix the bug locally, update my dependencies in B, run B and everything's fine. I check in obviously. Now I build A on Jenkins and afterwards B. I then get the newly built B and run it. The bug is still there. Hours later if I build B again it will kindly get the new A and the bug is gone..

So there must be a way to force jenkins to use the new A on its server. using mvn -u or mvn --update-snapshots will not help. It will check for updates and find none..

like image 683
Pete Avatar asked Aug 01 '12 09:08

Pete


People also ask

Does Jenkins cache builds?

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.

How do I clean up Maven?

Local Maven Repository location To clear/delete your local maven repository cache, simply delete the . m2/repository folder. The local repository path can also be configured in Maven setting. xml (either the global or the user one).

Does Maven have a cache?

At very simple form, the build cache Maven is essentially a hash function which takes Maven project and produces cache key for a project.

Where is the Maven cache?

The first place that Maven looks for artifacts is in the local repository, which is the local cache where Maven stores all of the artifacts it has downloaded or found elsewhere. The default location of the local repository is the . m2/repository/ directory under the user's home directory.


1 Answers

I believe there is no such caching behavior possible in Maven/Jenkins, as all your snapshot is built locally in the same instance of Jenkins. There is no need for the "update snapshot" option because you are not getting it from remote repo. However, I would recommend you to take a look in the repository setting in Jenkins. In Jenkins, we can change which maven repository to use (by default, it is shared by whole machine, but it can be changed to per-workspace or per-executor etc. (Under your project configuration, in Build -> Advanced, you can check for "Use private Maven repository", and in Manage Jenkins -> Configure System -> Maven Project Configuration, you can select the way to manage Local Maven Repository. I am suspecting you have changed it to "Local to executor"

If you have any setting that cause the build of A installed in a different repository that B use, you may hit problem you faced.

like image 128
Adrian Shum Avatar answered Sep 28 '22 09:09

Adrian Shum