无法在詹金斯奴隶上运行 gradle

发布于 2025-01-08 06:34:58 字数 571 浏览 4 评论 0原文

我已经配置了一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别挽留 2025-01-15 06:34:58

找到了解决方案!
我已经开始使用 gradle 包装器来运行 gradle 构建。
我做了两件事:

  1. 按照此 页面 上的说明创建 gradlew (和其他文件)并在我的存储库中检查它们
  2. 在 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:

  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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文