我创建了一个Gradle包装器
$ gradle wrapper --gradle-version 5.0 --distribution-type all
...现在有
$ ./gradlew -version
------------------------------------------------------------
Gradle 5.0
------------------------------------------------------------
Build time: 2018-11-26 11:48:43 UTC
Revision: 7fc6e5abf2fc5fe0824aec8a0f5462664dbcd987
Kotlin DSL: 1.0.4
Kotlin: 1.3.10
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 1.8.0_181 (Oracle Corporation 25.181-b13)
OS: Mac OS X 10.15.3 x86_64
然后,我使用正确的
rwx
权限在Git存储库的根目录中提交了包装文件。我的
gradle.properties
文件中包含以下内容org.gradle.jvmargs=-Xms512m -Xmx1024m -XX:MaxPermSize=1g -XX:ReservedCodeCacheSize=1048m
现在我写了一个简单的 Jenkins 管道,除了
node('build-node') {
stage('Clone') {
// clones the repo
}
stage('Build') {
sh "./gradlew -version"
}
}
当我运行管道时,我得到
+ ./gradlew -version
Error occurred during initialization of VM
Initial heap size set to a larger value than the maximum heap size
但是,当我以与Jenkins管道执行身份相同的用户(ubuntu)SSH到构建节点时,并运行相同的
./gradlew -version
命令时,我没有得到错误。为什么它在 Jenkins 管道中失败了?
最佳答案
在Jenkins-> Manage Jenkins-> Configure System中,需要设置此项
GRADLE_OPTS
-Xms512m -Xmx1024m
关于gradle - 为什么Gradle在Jenkins管道中使用 “Initial heap size set to a larger value than the maximum heap size”失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61803721/