OpenJDK9 (Docker), gradle 4.2.1, GitLab

OpenJDK9 (Docker), gradle 4.2.1, GitLab

我的项目使用 gradlew 4.2.1 在本地构建。但是当我 git 将其推送到 GitLab 时,出现以下错误。 我必须使用 Docker,所以我不知道我可以使用什么 Docker 图片来实现它。 这也是 git实验室-ci.yml:

# This file is a template, and might need editing before it works on your project.
# This template uses the java:8 docker image because there isn't any
# official Gradle image at this moment
#
# This is the Gradle build system for JVM applications
# https://gradle.org/
# https://github.com/gradle/gradle
image: openjdk:9-jdk

# Disable the Gradle daemon for Continuous Integration servers as correctness
# is usually a priority over speed in CI environments. Using a fresh
# runtime for each build is more reliable since the runtime is completely
# isolated from any previous builds.
variables:
    GRADLE_OPTS: "-Dorg.gradle.daemon=false"

# Make the gradle wrapper executable. This essentially downloads a copy of
# Gradle to build the project with.
# https://docs.gradle.org/current/userguide/gradle_wrapper.html
# It is expected that any modern gradle project has a wrapper
before_script:
    - chmod +x gradlew

# We redirect the gradle user home using -g so that it caches the
# wrapper and dependencies.
# https://docs.gradle.org/current/userguide/gradle_command_line.html
#
# Unfortunately it also caches the build output so
# cleaning removes reminants of any cached builds.
# The assemble task actually builds the project.
# If it fails here, the tests can't run.
build:
  stage: build
  script:
    - ./gradlew -g /cache/.gradle clean assemble
  allow_failure: false
  artifacts:
    name: "AudioBot"
    paths:
      - build/libs/*.jar

此处错误:

Exception in thread "main" javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty at java.base/sun.security.ssl.Alerts.getSSLException(Alerts.java:214) at java.base/sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1969) at java.base/sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1921) at java.base/sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1904) at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1436) at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413) at java.base/sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:567) at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1563) at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1491) at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:236) at org.gradle.wrapper.Download.downloadInternal(Download.java:66) at org.gradle.wrapper.Download.download(Download.java:51) at org.gradle.wrapper.Install.call(Install.java:62) at org.gradle.wrapper.Install.call(Install.java:48) at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69) at org.gradle.wrapper.Install.createDist(Install.java:48) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61) Caused by: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty at java.base/sun.security.validator.PKIXValidator.(PKIXValidator.java:89) at java.base/sun.security.validator.Validator.getInstance(Validator.java:181) at java.base/sun.security.ssl.X509TrustManagerImpl.getValidator(X509TrustManagerImpl.java:330) at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrustedInit(X509TrustManagerImpl.java:180) at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:192) at java.base/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:133) at java.base/sun.security.ssl.ClientHandshaker.checkServerCerts(ClientHandshaker.java:1825) at java.base/sun.security.ssl.ClientHandshaker.certificateStatus(ClientHandshaker.java:1676) at java.base/sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:272) at java.base/sun.security.ssl.Handshaker.processLoop(Handshaker.java:1086) at java.base/sun.security.ssl.Handshaker.processRecord(Handshaker.java:1020) at java.base/sun.security.ssl.SSLSocketImpl.processInputRecord(SSLSocketImpl.java:1137) at java.base/sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1074) at java.base/sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973) at java.base/sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1402) at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1429) ... 14 more Caused by: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty at java.base/java.security.cert.PKIXParameters.setTrustAnchors(PKIXParameters.java:200) at java.base/java.security.cert.PKIXParameters.(PKIXParameters.java:120) at java.base/java.security.cert.PKIXBuilderParameters.(PKIXBuilderParameters.java:104) at java.base/sun.security.validator.PKIXValidator.(PKIXValidator.java:86) ... 29 more ERROR: Job failed: exit code 1

为了测试,您可以在 docker-library/openjdk 的基础上制作一个。

docker-library/openjdk issue 19
ca-certificates-java.postinst configure 应该在那里,因为 PR 111, but if another approach mentioned in "Error - trustAnchors parameter must be non-empty",您可以在自定义图像中对其进行测试。

请注意 moby/moby issue 18180 曾经受到影响 ca-certificates-java.postinst configure,但现在应该没问题。

这可能是 Docker 图像中来自 Debian 的错误。我认为他们正在努力:https://github.com/docker-library/openjdk/issues/145

要立即解决此问题,您可以使用 jdk-9-slim 图像。只需添加 -slim.