OpenJDK9(Docker),gradle 4.2.1,GitLab

时间:2017-10-14 05:00:56

标签: java docker gitlab-ci java-9

我的项目使用graddlew 4.2.1在本地构建。但是当我把它推到GitLab时,我得到下面的错误。 我必须使用Docker,因此我不知道我可以使用什么Docker Image才能工作。这也是gitlab-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

这里的错误:

  

线程“main”中的异常javax.net.ssl.SSLException:   java.lang.RuntimeException:意外错误:   java.security.InvalidAlgorithmParameterException:trustAnchors   参数必须是非空的   java.base / sun.security.ssl.Alerts.getSSLException(Alerts.java:214)at at   java.base / sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1969)     在   java.base / sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1921)     在   java.base / sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1904)     在   java.base / sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1436)     在   java.base / sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)     在   java.base / sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:567)     在   java.base / sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)     在   java.base / sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1563)     在   java.base / sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1491)     在   java.base / sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:236)     在org.gradle.wrapper.Download.downloadInternal(Download.java:66)at   org.gradle.wrapper.Download.download(Download.java:51)at   org.gradle.wrapper.Install $ 1.call(Install.java:62)at   org.gradle.wrapper.Install $ 1.call(Install.java:48)at   org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)     在org.gradle.wrapper.Install.createDist(Install.java:48)at   org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)     在   org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)   引起:java.lang.RuntimeException:意外错误:   java.security.InvalidAlgorithmParameterException:trustAnchors   参数必须是非空的   java.base / sun.security.validator.PKIXValidator。(PKIXValidator.java:89)     在   java.base / sun.security.validator.Validator.getInstance(Validator.java:181)     在   java.base / sun.security.ssl.X509TrustManagerImpl.getValidator(X509TrustManagerImpl.java:330)     在   java.base / sun.security.ssl.X509TrustManagerImpl.checkTrustedInit(X509TrustManagerImpl.java:180)     在   java.base / sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:192)     在   java.base / sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:133)     在   java.base / sun.security.ssl.ClientHandshaker.checkServerCerts(ClientHandshaker.java:1825)     在   java.base / sun.security.ssl.ClientHandshaker.certificateStatus(ClientHandshaker.java:1676)     在   java.base / sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:272)     在   java.base / sun.security.ssl.Handshaker.processLoop(Handshaker.java:1086)     在   java.base / sun.security.ssl.Handshaker.processRecord(Handshaker.java:1020)     在   java.base / sun.security.ssl.SSLSocketImpl.processInputRecord(SSLSocketImpl.java:1137)     在   java.base / sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1074)     在   java.base / sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)     在   java.base / sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1402)     在   java.base / sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1429)     ... 14更多引起:   java.security.InvalidAlgorithmParameterException:trustAnchors   参数必须是非空的   java.base / java.security.cert.PKIXParameters.setTrustAnchors(PKIXParameters.java:200)     在   java.base / java.security.cert.PKIXParameters中。(PKIXParameters.java:120)     在   java.base / java.security.cert.PKIXBuilderParameters中。(PKIXBuilderParameters.java:104)     在   java.base / sun.security.validator.PKIXValidator。(PKIXValidator.java:86)     ... 29更多错误:作业失败:退出代码1

2 个答案:

答案 0 :(得分:4)

这是Docker镜像中Debian的错误。他们正在研究它:https://github.com/docker-library/openjdk/issues/145

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

答案 1 :(得分:1)

为了进行测试,您可以在docker-library/openjdk上建立一个基础。

docker-library/openjdk issue 19
PR 111以来,ca-certificates-java.postinst configure应该在那里,但如果在" Error - trustAnchors parameter must be non-empty"中提到了另一种方法,您可以在自定义图片中对其进行测试。

请注意,moby/moby issue 18180一旦受到影响ca-certificates-java.postinst configure,但现在应该可以。