这是一起由Nexus证书导入错误造成的Jenkins运行异常。

最近,同事修改了Nexus服务器的host name,结果导致Jenkins里的任务全都执行不了了。虽然job的配置都已经更新指向新的Nexus地址,但是,当job将编译好的artifact上传到Nexus服务器时Jenkins总是报Peer not authenticated错误。Jenkins master/slave通过SSL访问Nexus。

...
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving D:\workspace\workspace\mmmmmmm parent\pom.xml to com.mmmmmmm/parent/2.1.0.2-SNAPSHOT/parent-2.1.0.2-SNAPSHOT.pom
channel stopped
Maven RedeployPublisher use remote slave001 maven settings from : d:\apache-maven-3.3.9\conf\settings.xml
[INFO] Deployment in https://nnnnnnn.mmmmmmm.local:10000/nexus/content/repositories/mmmmmmm-next-snapshots/ (id=snapshots,uniqueVersion=true)
Deploying the main artifact parent-2.1.0.2-SNAPSHOT.pom
Downloading: https://nnnnnnn.mmmmmmm.local:10000/nexus/content/repositories/mmmmmmm-next-snapshots/de/mmmmmmm/parent/2.1.0.2-SNAPSHOT/maven-metadata.xml
ERROR: Failed to retrieve remote metadata com.mmmmmmm:parent:2.1.0.2-SNAPSHOT/maven-metadata.xml: Could not transfer metadata com.mmmmmmm:parent:2.1.0.2-SNAPSHOT/maven-metadata.xml from/to snapshots (https://nnnnnnn.mmmmmmm.local:10000/nexus/content/repositories/mmmmmmm-next-snapshots/): peer not authenticated
org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to retrieve remote metadata com.mmmmmmm:parent:2.1.0.2-SNAPSHOT/maven-metadata.xml: Could not transfer metadata com.mmmmmmm:parent:2.1.0.2-SNAPSHOT/maven-metadata.xml from/to snapshots (https://nnnnnnn.mmmmmmm.local:10000/nexus/content/repositories/mmmmmmm-next-snapshots/): peer not authenticated
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:143)
    at hudson.maven.reporters.MavenArtifactRecord.deploy(MavenArtifactRecord.java:193)
    at hudson.maven.RedeployPublisher.perform(RedeployPublisher.java:176)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
    at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1037)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668)
    at hudson.model.Run.execute(Run.java:1763)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:529)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)
Caused by: org.eclipse.aether.deployment.DeploymentException: Failed to retrieve remote metadata com.mmmmmmm:parent:2.1.0.2-SNAPSHOT/maven-metadata.xml: Could not transfer metadata com.mmmmmmm:parent:2.1.0.2-SNAPSHOT/maven-metadata.xml from/to snapshots (https://nnnnnnn.mmmmmmm.local:10000/nexus/content/repositories/mmmmmmm-next-snapshots/): peer not authenticated
    at org.eclipse.aether.internal.impl.DefaultDeployer.upload(DefaultDeployer.java:470)
    at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:314)
    at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:269)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:413)
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:139)
    ... 11 more
Caused by: org.eclipse.aether.transfer.MetadataTransferException: Could not transfer metadata com.mmmmmmm:parent:2.1.0.2-SNAPSHOT/maven-metadata.xml from/to snapshots (https://nnnnnnn.mmmmmmm.local:10000/nexus/content/repositories/mmmmmmm-next-snapshots/): peer not authenticated
    at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$5.wrap(WagonRepositoryConnector.java:995)
    at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$5.wrap(WagonRepositoryConnector.java:983)
    at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:725)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.maven.wagon.TransferFailedException: peer not authenticated
    at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:892)
    at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:116)
    at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)
    at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
    at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:660)
    ... 4 more
Caused by: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
    at sun.security.ssl.SSLSessionImpl.getPeerCertificates(Unknown Source)
    at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:126)
    at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:437)
    at org.apache.maven.wagon.shared.http4.ConfigurableSSLSocketFactoryDecorator.connectSocket(ConfigurableSSLSocketFactoryDecorator.java:64)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
    at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:643)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
    at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.execute(AbstractHttpClientWagon.java:746)
    at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:886)
    ... 8 more
[INFO] Deployment failed after 0.48 sec
Build step 'Deploy artifacts to Maven repository' changed build result to FAILURE
Finished: FAILURE

问题初步分析。在修改Nexus host name之前,Jenkins master/slave一直可以访问Nexus,各个job也都工作正常。而出现的问题是Peer not authenticated,说明Jenkins和Nexus的SSL连接上出现了问题。由于是SSL连接,而且Nexus又刚刚改掉了host name,所以初步怀疑是证书(certificate)出了问题。

新证书是同事做好了的,所以我只需要从Nexus的keystore中导出证书(cert),并将cert导入到Jenkins的master和slave JDK的cacerts里就好了。接下来使用portacle工具将cert导入到Jenkins master设备的JDK cacerts文件中,以及slave的JDK cacerts文件中。重启Jenkins和slave, 尝试执行job。问题依旧存在。

经过查阅资料,仔细对比,发现Jenkins自带JRE,其并不是使用的标准安装的JDK。所以,Nexus的新证书导入到标准JDK的cacerts文件中对于Jenkins来说是无用的。而,Jenkins使用的JRE定位在这里:C:\medavis\service\Jenkins\jre。Nexus的新证书应该导入到这个JRE的cacerts文件中。遂立即导入证书,重启Jenkins master。然后执行job,确认问题已经解决。

Jenkins在deploy maven artifact时报Peer not authenticated.的更多相关文章

  1. eclipse 配置Maven问题解决办法:新建maven工程时报错:Could not resolve archetype org.apache.maven.archetypes .

    此文乃本作者配置maven,被其折磨n天,究极解决方案,好文要顶啊.欢迎致电: zhe-jiang.he@hp.com 首先各maven.archetypes下载地址: http://mirrors. ...

  2. [原]Jenkins(二)---jenkins之Git+maven+jdk+tomcat

    /** * lihaibo * 文章内容都是根据自己工作情况实践得出. *版权声明:本博客欢迎转发,但请保留原作者信息! http://www.cnblogs.com/horizonli/p/5331 ...

  3. k8s下的jenkins如何设置maven

    关于k8s环境的jenkins集群 k8s下搭建了jenkins集群后,执行任务时会新建pod,任务完成后pod被销毁,架构如下图所示: 在k8s搭建jenkins集群的步骤请参照<> 关 ...

  4. 解决:mvn archetype:create Abstract class or interface 'org.apache.maven.artifact.repository.ArtifactRepository' cannot be instantiated

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2 .3:create (default- ...

  5. jenkins+docker 持续构建非docker in docker jenkins docker svn maven

    工欲善其事必先利其器,为了解脱程序员的,我们程序员本身发明了很多好用的工具,通过各种工具的组合来达到我们想要的结果 本文采用jenkins docker svn maven作为相关工具,项目sprin ...

  6. Jenkins Jenkins结合GIT Maven持续集成环境配置

    Jenkins结合GIT Maven持续集成环境配置   by:授客 QQ:1033553122 安装Git插件 1 安装Git客户端 1 安装JAVA JDK及MAVEN 2 Jenkins JDK ...

  7. 在jenkins中调用maven的变量

    Maven内置变量说明: ${basedir} 项目根目录(即pom.xml文件所在目录) ${project.build.directory} 构建目录,缺省为target目录 ${project. ...

  8. Jenkins实现SVN+Maven+Java项目的持续集成

    Jenkins 2.46.1 Centos 7.3 JDK 7 安装jdk/maven/svn 在Jenkins所在的Linux机器安装jdk和maven,步骤就不说了,下面是环境变量: export ...

  9. 创建Maven Module时报错:The parent project must have a packaging type of POM

    创建Maven Module时报错:The parent project must have a packaging type of POM 解决的办法,是把父项目的Packaging改成pom:

随机推荐

  1. java websocket client

    websocket是H5新推出的协议,一般用于前端,但是在实际项目中我们需要用java代码来获取一些设备的实时运行数据,在后台处理后推送的前台界面,为了保证实时性,我们需要用到websocket协议, ...

  2. jquery colsest的用法

    如果有class,就是他自己,没有就在父级去找 e=e||window.event; var target=e.srcElement?e.srcElement:e.target; var parent ...

  3. c#实现gzip压缩解压缩算法:byte[]字节数组,文件,字符串,数据流的压缩解压缩

    转载:https://blog.csdn.net/luanpeng825485697/article/details/78165788 我测试了下压缩byte[],是可以的 using System; ...

  4. unity换装系统+网格合并

    这里的做法是模型把所有衣服全部穿上作为一个资源 然后还有一个只有骨骼信息的骨架资源 将这2个制作好了Prefab 模型部件数据 资源数据 [代码] using System.Collections; ...

  5. 用.net 2.0(或.net 3.5)开发的程序在.net 4.0的环境中运行的解决方案

    引用:.NET2.0程序集无法在.net 4.0 中运行的解决方案 1. 原来是在.net 2.0 (VS2008)的环境下的程序,通过升级到.net 4.0 (VS2013)导致程序运行不了 提示需 ...

  6. list-iscroll5.2

    简介 iScroll是一个高性能,资源占用少,无依赖,多平台的JavaScript滚动插件. 它可以在桌面,移动设备和智能电视平台上工作.它一直在大力优化性能和文件大小以便在新旧设备上提供最顺畅的体验 ...

  7. golang基础---Slice切片

    切片Slice在go语言中是单独的类型(指向底层的数组),不同于python(对可迭代对象操作的工具),注意区分数组和slice的区别 定义一个空slice,格式var s []int,这种既没有长度 ...

  8. ansible roles 目录规范

    我的ansible roles项目的目录结构: (ansible_venv) [root@localhost ansible_home]# tree ansible_playbooks/ ansibl ...

  9. Nginx配置整理

    不论是本地开发,还是远程到 Server 开发,还是给提供 demo 给人看效果,我们时常需要对 Nginx 做配置,Nginx 的配置项相当多,如果考虑性能配置起来会比较麻烦.不过,我们往往只是需要 ...

  10. img图片加载失败默认图片

    <img :src="item.goods_pic" onerror="javascript:this.src='../static/images/default. ...