You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用gradle:jdk8镜像时GitLab CI中keytool报-cacerts非法选项错误

Fixing the keytool Error with gradle:jdk8 in GitLab CI

The error Illegal option: -cacerts pops up because the keytool command syntax differs between JDK 8 and JDK 11. In JDK 8, you can’t use -cacerts as a standalone option—you need to explicitly point to the cacerts keystore file using the -keystore parameter instead.

Here’s the corrected gitlab-ci.yml configuration that works with the gradle:jdk8 image:

image: gradle:jdk8
stages:
  - build
  - publish
before_script:
  - wget -P /tmp http://www.some.com/SOME.crt
  - keytool -importcert -trustcacerts -file /tmp/SOME.crt -keystore $JAVA_HOME/jre/lib/security/cacerts -alias "Some" -storepass changeit -noprompt

What’s the change?

  • We replaced -cacerts with -keystore $JAVA_HOME/jre/lib/security/cacerts: In JDK 8, the cacerts file lives in the jre/lib/security subfolder of your JAVA_HOME directory. Using the $JAVA_HOME environment variable makes this path dynamic and reliable across different JDK 8 setups.
  • The rest of the command remains identical—we’re still importing the certificate into the trusted CA store, just using the syntax that JDK 8’s keytool recognizes.

This adjustment will fix the illegal option error and let your pipeline run smoothly with the gradle:jdk8 image.

内容的提问来源于stack exchange,提问作者Valeriy K.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 07:52:52