Can't run gradle on jenkins slave

倾然丶 夕夏残阳落幕 提交于 2019-12-12 15:28:36

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/9381320/cant-run-gradle-on-jenkins-slave

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!