jenkins无法访问https解决方法

mac上,jenkins在构建时需要访问https的url,报错如下:

Gradle 5.0\. Set the '[rootProject.name](rootProject.name)' or adjust the 'include' statement (see [https://docs.gradle.org/4.4/dsl/org.gradle.api.initialization.Settings.html#org.gradle.api.initialization.Settings:include(java.lang.String](https://docs.gradle.org/4.4/dsl/org.gradle.api.initialization.Settings.html#org.gradle.api.initialization.Settings:include(java.lang.String)[]) for more details).

FAILURE: Build failed with an exception.

* What went wrong:

A problem occurred configuring root project 'saas android package'.

> Could not resolve all files for configuration ':classpath'.

 > Could not resolve [com.android.tools.build:gradle:3.1.2](com.android.tools.build:gradle:3.1.2).

 Required by:

 project :

 > Could not resolve [com.android.tools.build:gradle:3.1.2](com.android.tools.build:gradle:3.1.2).

 > Could not get resource '[https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom](https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom)'.

 > Could not GET '[https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom](https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom)'.

 > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

 > Could not resolve [com.android.tools.build:gradle:3.1.2](com.android.tools.build:gradle:3.1.2).

 > Could not get resource '[https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom](https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom)'.

 > Could not GET '[https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom](https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom)'.

 > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

 > Could not resolve [org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.40](org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.40).

 Required by:

 project :

 > Could not resolve [org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.40](org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.40).

 > Could not get resource '[https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.40/kotlin-gradle-plugin-1.2.40.pom](https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.40/kotlin-gradle-plugin-1.2.40.pom)'.

 > Could not GET '[https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.40/kotlin-gradle-plugin-1.2.40.pom](https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.40/kotlin-gradle-plugin-1.2.40.pom)'.

 > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

 > Could not resolve [org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.40](org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.40).

 > Could not get resource '[https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.40/kotlin-gradle-plugin-1.2.40.pom](https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.40/kotlin-gradle-plugin-1.2.40.pom)'.

 > Could not GET '[https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.40/kotlin-gradle-plugin-1.2.40.pom](https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.40/kotlin-gradle-plugin-1.2.40.pom)'.

 > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

* Try:

解决方法:

  1. 在Mac中是Keychain,打开之后找到StartCom的证书,然后右键导出成一个.cer文件,命名为startcom.cer。

  2. keytool -import -alias startcom -keystore /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/security/cacerts -file startcom.cer

  3. keytool -list -keystore /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/security/cacerts | less

  4. 启动jenkins
    java -Djavax.net.ssl.trustStore=”/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/security/cacerts” -Djavax.net.ssl.keyStorePassword=changeit -jar /usr/local/Cellar/jenkins/2.124/libexec/jenkins.war –httpPort=8080

  5. 至此,问题解决

文章地址:
https://www.cnblogs.com/cuiliqiang/p/4039395.html

    原文作者:慕小孩
    原文地址: https://www.jianshu.com/p/a438cb981c6b
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞