Jenkins 使用 Gradle 守护进程构建失败
Jenkins Builds Fail Using the Gradle Daemon
在尝试提高我的 Gradle Android 构建的性能时,我偶然发现了 Gradle 守护进程,并且一直在使用它进行本地构建并取得了巨大成功。
但是,当 运行在 Ubuntu 14.04 上使用 Jenkins 时,构建会间歇性地失败:
Starting process 'Gradle Test Executor 2'. Working directory: /tmp/myproject/android/example Command: /usr/lib/jvm/java-8-oracle/bin/java -Djava.awt.headless=true -Djava.security.manager=worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea -cp /data/var/lib/jenkins/.gradle/caches/2.14.1/workerMain/gradle-worker.jar worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 2'
Successfully started process 'Gradle Test Executor 2'
Daemon vm is shutting down... The daemon has exited normally or was terminated in response to a user interrupt.
Starting process 'Gradle Test Executor 3'. Working directory: /tmp/myproject/android/example Command: /usr/lib/jvm/java-8-oracle/bin/java -Djava.awt.headless=true -Djava.security.manager=worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea -cp /[...]/.gradle/caches/2.14.1/workerMain/gradle-worker.jar worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 3'
----- End of the daemon log -----
FAILURE: Build failed with an exception.
* What went wrong:
Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
Error: Failed to run test (./gradlew --console=plain --info test -p myproject).
FAILURE: Build failed with an exception.
多个构建可以运行并行进行。如果我 运行 在没有其他构建 运行ning 时手动构建,我将无法重现它。 Someone else 有这个问题,但推荐的解决方案是禁用 Gradle 守护进程,我不想这样做。我认为大型并发构建环境正是 Gradle Daemon 旨在优化的。
或者,如果我不能让 Gradle 守护进程在 Jenkins 下可靠地工作,为什么不呢?谢谢!
Gradle 守护程序自版本 3.0
起默认启用。但是,official documentation 直到 4.2.1
声明您不应该在持续集成服务器中使用守护进程。
It is recommended that the Daemon is used in all developer environments. It is recommend to disable the Daemon for Continuous Integration and build server environments.
The Daemon enables faster builds, which is particularly important when a human is sitting in front of the build. For CI builds, stability and predictability is of utmost importance. Using a fresh runtime (i.e. process) for each build is more reliable as the runtime is completely isolated from previous builds.
此建议此后有所更改,请参阅 Disabling the Daemon
Since Gradle 3.0, we enable Daemon by default and recommend using it for both developers' machines and Continuous Integration servers. However, if you suspect that Daemon makes your CI builds unstable, you can disable it to use a fresh runtime for each build since the runtime is completely isolated from any previous builds.
在尝试提高我的 Gradle Android 构建的性能时,我偶然发现了 Gradle 守护进程,并且一直在使用它进行本地构建并取得了巨大成功。
但是,当 运行在 Ubuntu 14.04 上使用 Jenkins 时,构建会间歇性地失败:
Starting process 'Gradle Test Executor 2'. Working directory: /tmp/myproject/android/example Command: /usr/lib/jvm/java-8-oracle/bin/java -Djava.awt.headless=true -Djava.security.manager=worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea -cp /data/var/lib/jenkins/.gradle/caches/2.14.1/workerMain/gradle-worker.jar worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 2'
Successfully started process 'Gradle Test Executor 2'
Daemon vm is shutting down... The daemon has exited normally or was terminated in response to a user interrupt.
Starting process 'Gradle Test Executor 3'. Working directory: /tmp/myproject/android/example Command: /usr/lib/jvm/java-8-oracle/bin/java -Djava.awt.headless=true -Djava.security.manager=worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea -cp /[...]/.gradle/caches/2.14.1/workerMain/gradle-worker.jar worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 3'
----- End of the daemon log -----
FAILURE: Build failed with an exception.
* What went wrong:
Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
Error: Failed to run test (./gradlew --console=plain --info test -p myproject).
FAILURE: Build failed with an exception.
多个构建可以运行并行进行。如果我 运行 在没有其他构建 运行ning 时手动构建,我将无法重现它。 Someone else 有这个问题,但推荐的解决方案是禁用 Gradle 守护进程,我不想这样做。我认为大型并发构建环境正是 Gradle Daemon 旨在优化的。
或者,如果我不能让 Gradle 守护进程在 Jenkins 下可靠地工作,为什么不呢?谢谢!
Gradle 守护程序自版本 3.0
起默认启用。但是,official documentation 直到 4.2.1
声明您不应该在持续集成服务器中使用守护进程。
It is recommended that the Daemon is used in all developer environments. It is recommend to disable the Daemon for Continuous Integration and build server environments.
The Daemon enables faster builds, which is particularly important when a human is sitting in front of the build. For CI builds, stability and predictability is of utmost importance. Using a fresh runtime (i.e. process) for each build is more reliable as the runtime is completely isolated from previous builds.
此建议此后有所更改,请参阅 Disabling the Daemon
Since Gradle 3.0, we enable Daemon by default and recommend using it for both developers' machines and Continuous Integration servers. However, if you suspect that Daemon makes your CI builds unstable, you can disable it to use a fresh runtime for each build since the runtime is completely isolated from any previous builds.