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