詹金斯 Gradle "Could not reserve enough space for object heap"

Jenkins Gradle "Could not reserve enough space for object heap"

我正在尝试 运行 在 Jenkins 上使用 Gradle 构建任务,但是 Gradle 无法 运行。

Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.

参数-Xmx2048m显然用在了Java到运行Gradle的过程中。 如果这个参数有问题,我应该在哪里更改它? (詹金斯配置为 -Xmx1024m)。我 运行 在具有 1GB RAM 的设备上运行它(在 运行 运行任务之前大约有 700 - 500MB 可用空间)。

完整日志:http://pastebin.com/BBsjp5pZ

Jenkins manual 谈到 "GRADLE_OPTS"。

Gradle build steps You can set the -Xmx or -XX:MaxPermSize by adding a GRADLE_OPTS global environment variable in the Jenkins global configuration. To do this, click Manage Jenkins, then Configure System. In the Global properties section, click the Environment Variables checkbox, then add a new environment variable called GRADLE_OPTS with the value set appropriately, similar to the screen shot above regarding MAVEN_OPTS

我必须修改项目文件夹中的 gradle.properties 文件

原始设置:

org.gradle.jvmargs=-Xmx2048m

新设置:

org.gradle.jvmargs=-Xmx512m -Xms100m

参考文献:

Where should I put gradle.properties in Jenkins https://docs.gradle.org/current/userguide/build_environment.html