Can't start gradle program in Jenkins

I installed the Gradle plugin for Jenkins. When I try to build a 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 $ gradle clean -b build/build.gradle from the command line works as expected.

+48
jenkins gradle
Dec 27 '11 at 16:16
source share
7 answers

I had the same problem, and I found that the problem for me was in the gradle version in the project configuration. It was set to default , and when I installed it in the gradle version that I pointed out in the plugin configuration, in Manage Jenkins > strong configuration options >, it found gradle and worked correctly.

This is a tough debugging issue, and I hope it saves a little time.

+57
Jan 31 '12 at 15:48
source share

Mastering_the_Object's solution indicated that it worked for me too, just to clarify the steps there:
just installing the Gradle plugin in Jenkins is not enough, you should also go to:
Jenkins-> Manage Jenkins-> Configure Jenkins-> Configure System.
In the "Gradle Settings" section, enter a name (it displays as the version in the project configuration), select the "Install automatically" checkbox, and select the version. Then you can select "Gradle version" in the project configuration.

+20
Apr 16 '14 at 12:00
source share

When running Gradle on a CI machine such as Jenkins, it is most convenient to use Wrapper Gradle.

On your development machine, go to the root project directory and run

 gradle wrapper 

Then check the received files in the source control system. After that, you do not need to install anything on your Jenkins server if you need to change Gradle versions. Just set up your Jenkins work as follows:

enter image description here

Quote from Gradle User Guide :

By distributing the wrapper with your project, anyone can work with it without installing Gradle first. Even better, users in the assembly are guaranteed to use the version of Gradle that the assembly was designed to work. Of course, this is also great for continuous integration servers (that is, servers that regularly project), since it does not require configuration on the server.

+11
Jan 05 '15 at 15:52
source share

I was getting this error using the Gradle shell, was able to fix my broken assembly as follows:

  • Go to Jenkins Management -> Global Tool Configuration -> Gradle -> Add Gradle , specify a name
  • Go to Jenkins -> (your work) -> Configure -> Build , select "Invoke Gradle" and change the Gradle version from (default) to the named version
+6
Feb 03 '17 at 23:46 on
source share

Jenkins cannot find the gradle executable. I have never done a gradle wrapper for work. Follow these steps:

  • Download gradle ( http://gradle.org/downloads )
  • unpack it, for example, / usr / local / lib / gradle,
  • open / etc / profile and add the following two lines:
  • export GRADLE_HOME = / usr / local / lib / gradle
  • export PATH = $ PATH: $ GRADLE_HOME / bin

It works for my jenkins installation .

ps. I answer this old question because it is a common problem when setting up gradle with jenkins. I spent some time trying to make the gradle wrapper work without success before.

+1
Sep 18 '12 at 20:21
source share

Both @Skarab and a number of other solutions are used to make it work.

Download gradle ( http://gradle.org/downloads ), unzip it, for example, / usr / local / lib / gradle, open / etc / profile and add the following two lines: export GRADLE_HOME = / usr / local / lib / gradle export PATH = $ PATH: $ GRADLE_HOME / bin

Then under Jenkins Management> Configure System> Gradle defined by GRADLE_HOME and gave this gradle a name setting

Then {this might be a mistake} for the project, change the default gradle version to the one I defined above

+1
Jun 25 '14 at 13:14
source share

As others have noted, this is because Jenkins cannot find the gradle executable.

None of the published solutions worked for me, but I was able to fix this problem by adding the gradle dir directory to the path set in .bashrc for the build account on the slave assembly. Failed to modify .profile file and also set PATH in jenkins node configuration.

Some posts will suggest setting the gradle path in the tool menu, but there was no gradle entry there (perhaps due to regression / design changes in the gradle plugin?).

In any case, the best test I found (with the exception of running the build and viewing the failure) was to run env on ssh:

 ssh <host> env 

and check the PATH variable so specified; if gradle is not in this path, you probably cannot start it from jenkins.

0
Feb 26 '14 at 5:04
source share



All Articles