Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't run gradle on jenkins slave

I've configured a jenkins ubuntu slave and I want to run my gradle build on it(with gradle plugin). The problem is that when running the jenkins build job I get:

 $ gradle --no-daemon --info clean build
 FATAL: command execution failed
 java.io.IOException: Cannot run program "gradle" (in directory "/var/jenkins/workspace/dadi"): java.io.IOException: error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
    at hudson.Proc$LocalProc.<init>(Proc.java:244)
    at hudson.Proc$LocalProc.<init>(Proc.java:216)

When running the same gradle command on the command line of the slave(same user) it runs successfully.

like image 390
eldad levy Avatar asked Dec 04 '25 11:12

eldad levy


1 Answers

Found a workaround solution! I've start using gradle wrapper in order to run the gradle build. I did 2 things:

  1. followed instructions on this page to create gradlew (and other files) and checked them in my repository
  2. in jenkins gradle plugin marked the build step to use gradle wrapper.

    task wrapper(type: Wrapper) { gradleVersion = '2.0' }

This above line would create.gradle folder & download required gradle version(mentioned in the task) every time gradle build is run, that means there is no need to check-in .gradle folder into your repository anymore.

Also had to rename gradlew to gradle.bat since the jenkins gradle plugin try to run the gradle.bat even on linux. That's it. working.

like image 52
eldad levy Avatar answered Dec 07 '25 16:12

eldad levy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!