kubesphere jenkins 构建java项目报错Could not parse metadata
问题描述:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-install) on project common-plugin-starter: Failed to install metadata com.neuron.framework:common-plugin-starter:0.0.2-SNAPSHOT/maven-metadata.xml: Could not parse metadata /root/.m2/repository/com/neuron/framework/common-plugin-starter/0.0.2-SNAPSHOT/maven-metadata-local.xml: in epilog non whitespace content is not allowed but got u (position: END_TAG seen ...</metadata>\nu... @21:2) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-install) on project common-plugin-starter: Failed to install metadata com.neuron.framework:common-plugin-starter:0.0.2-SNAPSHOT/maven-metadata.xml: Could not parse metadata /root/.m2/repository/com/neuron/framework/common-plugin-starter/0.0.2-SNAPSHOT/maven-metadata-local.xml: in epilog non whitespace content is not allowed but got u (position: END_TAG seen ...</metadata>\nu... @21:2)
报错中提示maven-metadata-local.xml无法解析,文件不允许非空白内容,在21行存在错误
排查思路:
1、首先可以确定的是并非项目代码问题,因为在另外一个Jenkins环境构建正常,且maven-metadata-local.xml是maven本地仓库缓存的相关文件,应该是kubesphere中的配置
2、在Jenkins构建过程中,进入Jenkins的worker容器查看文件内容,果然在21行存在错误
3、查看jenkins-casc-config文件,发现/root/.m2的文件是以hostPath的方式挂载的
4、那就去Jenkins worker运行的node节点中找找看,但是构建任务失败,刚刚的woker容器已经删掉了,这里只有三个node节点,索性挨个节点去查
node1:没有这个缓存目录
node2:存在缓存目录,但maven-metadata-local.xml文件和前面容器内查看的不一样,node2应该是正常文件
node3:也有缓存目录,查看maven-metadata-local.xml文件,很明显了,问题就在node3节点上
解决方法:
尝试将node3上的maven-metadata-local.xml文件bak掉,重新跑Jenkins构建任务,woker还是被调度到node3节点上运行,此时再查看目录下文件,发现自动重新创建了一份正确的maven-metadata-local.xml,构建任务也成功了!
至于问题的原因,那就是个迷了。。。