Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot run program "gradle" in Jenkins

Tags:

gradle

jenkins

I've installed the Gradle plugin for Jenkins. When I try to build the project I get the following error:

[workspace] $ gradle clean -b build/build.gradle FATAL: command execution failed java.io.IOException: Cannot run program "gradle" (in directory "/Users/Shared/Jenkins/Home/jobs/test/workspace"): 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)     at hudson.Launcher$LocalLauncher.launch(Launcher.java:707)     at hudson.Launcher$ProcStarter.start(Launcher.java:338)     at hudson.Launcher$ProcStarter.join(Launcher.java:345)     at hudson.plugins.gradle.Gradle.performTask(Gradle.java:201)     at hudson.plugins.gradle.Gradle.perform(Gradle.java:97)     at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)     at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:695)     at hudson.model.Build$RunnerImpl.build(Build.java:178)     at hudson.model.Build$RunnerImpl.doRun(Build.java:139)     at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:465)     at hudson.model.Run.run(Run.java:1404)     at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)     at hudson.model.ResourceController.execute(ResourceController.java:88)     at hudson.model.Executor.run(Executor.java:238) Caused by: java.io.IOException: error=2, No such file or directory     at java.lang.UNIXProcess.forkAndExec(Native Method)     at java.lang.UNIXProcess.<init>(UNIXProcess.java:53)     at java.lang.ProcessImpl.start(ProcessImpl.java:91)     at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)     ... 16 more Build step 'Invoke Gradle script' changed build result to FAILURE Build step 'Invoke Gradle script' marked build as failure Finished: FAILURE 

Running the task $ gradle clean -b build/build.gradle from the command line works as expected.

like image 249
Andreas Köberle Avatar asked Dec 27 '11 16:12

Andreas Köberle


People also ask

Does Jenkins support Gradle?

Gradle provides integration with several development tools and servers, including Eclipse, IntelliJ, Jenkins, and Android Studio.


2 Answers

I had the same issue and found that the problem for me was the gradle version in the project configuration. It was set to Default and when I set it to the gradle version I was pointing to in the plugin configuration in the Manage Jenkins > Configuration Options, It found gradle and worked properly.

This is a difficult issue to debug and I hope this saves someone else some time.

like image 145
Mastering_the_Object Avatar answered Oct 11 '22 11:10

Mastering_the_Object


Solution Mastering_the_Object pointed out worked form me too, just to clarify steps there:
just installing Gradle plugin in Jenkins is not enough, you must also go to:
Jenkins->Manage Jenkins->Configure Jenkins->Configure system.
Under "Gradle Installations" type in name (it appears as version in project configuration), check "Install automatically" and select version. Then you can select that "Gradle version" in project configuration.

like image 21
pad Avatar answered Oct 11 '22 12:10

pad