出现错误信息如下:
Waiting for Jenkins to finish collecting data
14:10:47 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:3.1.0:clean (default-clean) on project ruoyi: Failed to clean project: Failed to delete arb/jenkins/workspaceptyi/targetyi.jar -> [Help 1]
14:10:47 [JENKINS] Archiving arb/jenkins/workspaceptyi/pom.xml to com.ruoyi/ruoyi/2.2.0/ruoyi-2.2.0.pom
14:10:47 [ERROR]
14:10:47 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
14:10:47 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
14:10:47 [ERROR]
14:10:47 [ERROR] For more information about the errors and possible solutions, please read the following articles:
14:10:47 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
问题原因:
构建新建的target目录为root用户才可访问。
解决方法:
- 修改jenkins默认用户为root
// 打开jenkins配置文件
vi /etc/sysconfig/jenkins
// 将原来的jenkins用户修改为 root用户
JENKINS_USER="root"
- 更改jenkins三个文件夹的用户所有都和用户组
chown -R root:root /var/lib/jenkins
chown -R root:root /var/cache/jenkins
chown -R root:root /var/log/jenkins
- 重启Jenkins服务并检查运行Jenkins的用户是否已经切换为root
systemctl restart jenkins
- 查看Jenkins进程所属用户
ps -ef | grep jenkins
在这里感谢Semanteme,本文引用原文地址,通过他的文章解决了所遇到的问题,同时记录一下个人日志。