Jenkins构建始终返回Gradle 3.5 Package 器

tjjdgumg  于 2023-03-22  发布在  Jenkins
关注(0)|答案(1)|浏览(238)

尝试使用SDKMan提供的SDK构建Grails 5.3.2项目时,Jenkins因以下错误而停止:

| Error Command [war] error: Could not execute build using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-3.5-all.zip'. (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
org.gradle.tooling.GradleConnectionException: Could not execute build using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-3.5-all.zip'.
  at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:55)
  at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29)
  at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:43)
  at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:69)
  at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
  at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
  at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
  at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
  at org.gradle.tooling.internal.consumer.DefaultBuildLauncher.run(DefaultBuildLauncher.java:83)
  at org.grails.cli.gradle.GradleUtil$_runBuildWithConsoleOutput_closure3.doCall(GradleUtil.groovy:97)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at org.grails.cli.gradle.GradleUtil$_withProjectConnection_closure1.doCall(GradleUtil.groovy:78)
  at org.grails.cli.gradle.GradleUtil$_withProjectConnection_closure1.call(GradleUtil.groovy)
  at grails.io.support.SystemOutErrCapturer.withNullOutput(SystemOutErrCapturer.groovy:64)
  at org.grails.cli.gradle.GradleUtil.withProjectConnection(GradleUtil.groovy:77)
  at org.grails.cli.gradle.GradleUtil.runBuildWithConsoleOutput(GradleUtil.groovy:92)
  at org.grails.cli.gradle.GradleInvoker.invokeMethod(GradleInvoker.groovy:50)
  at assemble.run(assemble.groovy:21)
  at org.grails.cli.profile.commands.script.GroovyScriptCommand.handle(GroovyScriptCommand.groovy:153)
  at org.grails.cli.profile.AbstractProfile.handleCommand(AbstractProfile.groovy:475)
  at org.grails.cli.GrailsCli.handleCommand(GrailsCli.groovy:377)
  at org.grails.cli.GrailsCli.handleCommand(GrailsCli.groovy:350)
  at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:271)
  at org.grails.cli.GrailsCli.main(GrailsCli.groovy:159)
Caused by: org.gradle.api.GradleException: Unable to start the daemon process.

我相信,关键可能是Gradle 3.5不适合这里。在buildscript中,有:

export GRADLE_USER_HOME="/var/lib/jenkins/.sdkman/candidates/gradle/7.5.1/bin"
sdk use java 11.0.12-open
sdk use grails 5.3.2
sdk use gradle 7.5.1

并且生成日志确认正在使用这些设置:

[1;32mUsing java version 11.0.12-open in this shell.[0m
[1;32mUsing gradle version 7.5.1 in this shell.[0m
[1;32mUsing grails version 5.3.2 in this shell.[0m
...
WARNING: Illegal reflective access by org.gradle.internal.reflect.JavaMethod (file:/var/lib/jenkins/.sdkman/candidates/gradle/7.5.1/bin/wrapper/dists/gradle-3.5-all/exhrs6ca08n232b14ue48lbye/gradle-3.5/lib/gradle-base-services-3.5.jar) to method java.lang.ClassLoader.getPackages()

gradle.properties配置:gradleWrapperVersion=7.5.1 .
gradle-wrapper.properties配置:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

在以前的Grails 3项目版本中,gradle.properties实际上是在配置gradleWrapperVersion=3.5,Grails 3构建在同一个Jenkins示例上已经成功,为了避免Jenkins Grails 3项目构建的副作用,我将cleanWs()添加到Jenkinsfilestage('Build')中。

  • 这是什么问题?
  • 为什么构建总是引用回Gradle wrapper 3.5?我可以在哪里更改它?我在正在部署的the project's Grails 5 branch中找不到对版本3.5的引用。
  • Jenkins中是否有我缺少的配置选项?

多谢了!

sshcrbum

sshcrbum1#

在我的Jenkins构建配置中有两个主要的配置错误。
第一个是GRADLE_USER_HOME设置为Gradle SDK,但必须设置包含gradle.properties的目录。
第二个原因是,我有两个并行的构建作业,一个使用Grails 3(使用Gradle 3.5),另一个使用Grails 5(使用Gradle 7.5.1)。在构建脚本中的cd命令中,我不小心使用了旧构建作业的路径。
有了这些错误被修复,小的修正是很容易的,现在我有一个成功的建设。

相关问题