I used gradle build command in Centos 7 terminal and I got output:
FAILURE: Build failed with an exception.
* What we
I had the same problem. For me it worked after I exclude the .gradle folder if you can not delete try to rename.
For me, killing the Gradle daemon (gradle --stop
) really helped and fixed the issue.
If using the "Invoke Gradle script" build step, click on Advanced to reveal additional options. Locate "Force GRADLE_USER_HOME to use workspace" and check it.
If you have just updated your JDK version and you have set up a Gradle wrapper in your project, you may want to double-check the wrapper version supports your new JDK. If not, consider removing wrapper-related files from the project (gradlew
, gradlew.bat
and gradle/wrapper/*
) and re-generating them with the Gradle CLI, like so:
gradle wrapper --gradle-version <new-version-number>
e.g. gradle wrapper --gradle-version 4.10.2
This of course assumes your Gradle installation is up-to-date. If not, you will want to update that first.
Try setting your GRADLE_USER_HOME
variable to a folder where you have valid access. Then this error will go away.
For ex: I faced the same issue today while I was running gradle clean
command on a new slave machine.
My Gradle version was 2.3.
With --stacktrace, I came to know it was trying to create .gradle
folder for storing Gradle's cache data (while I invoked Gradle to run clean task on the slave) and it was trying to create that folder under /some/location/where/gradle/exists OR some /path/location/xxx/yyy where the user which was running Gradle on the slave machine didn't have valid access to write (create folder/files).
i.e. the user which I used to connect from Jenkins machine to the slave didn't have write access to touch
/mkdir
anything in the default location (where Gradle thought, OK I should create .gradle folder here).
To fix it, I added the above GRADLE_USER_HOME
variable in the slave's ENVIRONMENT Variable section. Now, as I have valid access in my home directory, I was OK.
Setting:
GRADLE_USER_HOME=~/gradle_2_3_cache/.gradle
resolved the issue.
You can set it to ~/.gradle as well. But I set it under a custom folder inside my ~
home directory (gradle_2_3_cache). This will help me in case I have another job/build run running on the same Slave machine but with a different Gradle version for ex: 2.5 etc version and if I want the .gradle
cache for 2.3 and 2.5/x version in separate folders.
NOTE: When using parallel
section within Jenkinsfile
, it's best to avoid Gradle greatness (i.e. using same Gradle's cache i.e. using same GRADLE_USER_HOME) as otherwise, you'll land into a mine of interesting issues as listed here: Jenkins - java.lang.IllegalArgumentException: Last unit does not have enough valid bits & Gradle error: Task 'null' not found in root project
I got the same error, got rid of it by using the correct version of Java / JDK. I was trying to build a Java 8 project with the Java 11 JDK. Check which version of Java JDK you are using.
To develop projects with different Java versions in parallel I now use jEnv to manage the different JDK versions: http://www.jenv.be/