Ivy, Ant, Jenkins - Is it good idea to to a <ivy:cleancache> on Jenkins builds?

ant, ivy, jenkins

Solution

In my opinion running the ivy cleancache task with every build is overkill and does away of one of the main benefits of using ivy, intelligent downloading of 3rd party dependencies.

Having said that as stated in the following related Maven question, all caches can become dirty and should be periodically purged:

When is it safe to delete the local Maven repository?

Couple of recommendations:

Use dedicated Jenkins job(s) to purge ivy cache

My first recommendation is to create a periodic Jenkins job that calls the following clean-all target in your build:

<target name="clean-all" depends="clean">
   <ivy:cleancache/>
</target>

This ensures that Jenkins decides when the cache is purged and you can schedule it to happen outside of the normal build times (for example 2am on 1st of every month)

Isolate each project by using multiple caches

My second recommendation increases the isolation between your project builds. Configure each project to have it's own private cache, using the caches directive. in you ivy settings file.

Problem

We are going to be using Ivy with Ant, and we'll have Jenkins do our builds. I originally thought that having Jenkins do a `<ivy:cleancache/>` before running a build would be a good idea. (It would be part of the mandatory "clean" target). However, I now see that `<ivy:cleancache>` doesn't simply clean up stuff from `<ivy:cachepath>`, but really removes the entire `$HOME/.ivy/cache` directory. My concern is that if Jenkins does a `<ivy:cleancache>` on all builds before they start, it will interfere with other builds that Jenkins could be executing. Is doing an `<ivy:cleancache>` a good idea, especially if a single user might be doing multiple builds at the same time? In fact, what happens when you do a `<ivy:cachepath pathid="compile.path"/>` in multiple projects? Does this also affect something like Jenkins? Will Jenkins become confused if multiple builds are building the `compile.cachepath` at the same time?

Original source

Related problems