无法在詹金斯奴隶上运行 gradle
我已经配置了一个 jenkins ubuntu 从机,我想在它上面运行我的 gradle 构建(使用 gradle 插件)。问题是,当运行 jenkins 构建作业时,我得到:
$ 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)
当在从机(同一用户)的命令行上运行相同的 gradle 命令时,它运行成功。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了解决方案!
我已经开始使用 gradle 包装器来运行 gradle 构建。
我做了两件事:
在 jenkins gradle 插件中标记了使用 gradle 包装器的构建步骤。
任务包装器(类型:包装器){
gradle版本 = '2.0'
}
这行将创建
.gradle
文件夹&每次运行 gradle 构建时下载所需的 gradle 版本(在任务中提到),这意味着不再需要将 .gradle 文件夹签入到您的存储库中。还必须将 gradlew 重命名为 gradle.bat,因为 jenkins gradle 插件甚至在 Linux 上也尝试运行 gradle.bat。
就是这样。在职的。
Found a workaround solution!
I've start using gradle wrapper in order to run the gradle build.
I did 2 things:
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 requiredgradle
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.