abnormal

After integrating the project into Jenkins, there is a small probability of building failure, and the error message output from Jenkins console is as follows:

Daemon vm is shutting down... The daemon has exited normally or was terminated in response to a user interrupt.
----- 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 --info or --debug option to get more log output. Run with --scan to get full insights.  * Get more help at https://help.gradle.org > Task :compileJava Build step 'Invoke Gradle script' changed build result to FAILURE Build step 'Invoke Gradle script' marked build as failure Copy the code

survey

After investigation, the problem may be the command./gradlew assembleDebug.

The official Gradle documentation states that daemons are enabled by default from Gradle 3.0 onwards.

The Gradle Daemon is enabled by default, and we recommend always enabling it. 
Copy the code

A Daemon is a long-running background process that stores build information in memory so that it can be reused during subsequent builds to speed up builds.

But in the documentation, there are hints as well.

If you run CI builds in ephemeral environments (such as containers) that do not reuse any processes, use of the Daemon will slightly decrease performance (due to caching additional information) for no benefit, and may be disabled. 
Copy the code

The idea is that if continuous integration is used to build projects, daemons are useless, and they degrade the performance of the system by storing extra information.

Solution 1

So how do I deactivate daemons in a continuous build?

It’s as simple as this:

./gradlew --no-daemon assembleDebug
Copy the code

Add a –no-daemon parameter to the command.

Solution 2

Issue in gradle configuration file [USER_HOME /. Gradle/gradle properties] add Settings.

org.gradle.daemon=false
Copy the code

User paths vary slightly from system to system

  • Windows: C:\Users<username>
  • Mac: /Users/
  • Linux: /home/

This article is formatted using MDNICE