Issue while building Gradle build from Jenkins

Hello,

Have anyone of you faced such an issue while building Gradle build from Jenkins. If so, please provide solutions. I thank you help in advance.

Issue: 1

  • What went wrong:

Could not create service of type TransformedFileCache using DependencyManagementGradleUserHomeScopeServices.createTransformedFileCache().
Issue: 2

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not create service of type FileHasher using GradleUserHomeScopeServices.createCachingFileHasher().
1 Like

Hi,

could it be possible the the Gradle user home is not writable from the Jenkins user? Sometimes the home directory for the user running Jenkins is read only.

Cheers,
Stefan

Thanks Stefan. Could there be other causes also?

What I understood is home directory of jenkin users running the job is not writable (/home/jenkin_user/.gradle) or related with gradle home directory?

Please provide more information.

Thanks.

Yes, my guess would be that the gradle user home directory (by default $HOME/.gradle) is not writeable. It needs to be writeable.

It is hard for me to give more help without knowing how you invoke Gradle (plugin, jenkinsfile) and about your environment.

We have checked, there is no permission issue.

We found that locks are not getting released. This is the file, which lock is not released:
.gradle/caches/transforms-1/transforms-1.lock

Once we clean up, jobs runs fine until lock issue occurs.

Strange, the lock should be released. Are there different Gradle daemons running for the same Gradle user home? What file system do you use for the Gradle user home?

We are using linux.

Need to check about the different Gradle daemons running on same gradle user home. If yes, what we need to do?

You’re most likely facing the same issue we are facing. If the GRADLE_USER_HOME is on a slow filesystem (read: not SSD / local hard disk, e.g. NFS), then you cannot run multiple Gradle instances concurrently without giving each one its own GRADLE_USER_HOME.

This has been a known shortcoming for years. Unfortunately, there’s no better solution than setting GRADLE_USER_HOME differently for each concurrently running instance. This means that all dependencies will need to be downloaded multiple times.

This problem gets even worse when you try to share a GRADLE_USER_HOME between different machines or docker containers, so definitely don’t do that!

You could be running into https://github.com/gradle/gradle/issues/851
To alleviate that, I am paying a price in infrastructure: each Jenkins agent needs its own Gradle cache. So I modified my Jenkins Pipeline code and the user scripts to accommodate that.