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:
解决方法:
在Mac中是Keychain,打开之后找到StartCom的证书,然后右键导出成一个.cer文件,命名为startcom.cer。
keytool -import -alias startcom -keystore /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/security/cacerts -file startcom.cer
keytool -list -keystore /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/security/cacerts | less
启动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至此,问题解决