jenkins 在构建项目时无法在maven仓库生成jar包父目录,导致无法下载jar包

本文详细解析了Jenkins在使用Maven构建项目时遇到的权限错误,即无法创建Maven本地仓库目录的问题,并提供了具体的解决方案,通过更改目录所属用户和组为jenkins来修复错误。

AI 驱动代码审查实战

Claude code-review 插件深度解析,把 AI 智能审查接进 CI/CD 流水线

jenkins制定完任务后,点击立即构建,控制台报错:
Failed to create parent directories for tracking file /usr/local/maven/repository/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom

报错解释
报错含义为:
无法生成目录 /usr/local/maven/repository/org/apache/maven/plugins/maven-clean-plugin/2.5
 

原因是:
jenkins 使用的 jenkins 用户和组,而  /usr/local/maven/repository 的用户和组是 root。
 

解决方案:

改变  目录 /usr/local/maven/repository 的用户组 为 jenkins 即可。

chown -R jenkins:jenkins /usr/local/maven/repository


问题及分析和解决方案详情如下:

问题报错信息如图:

查看 /usr/local/maven/repository 目录所属用户和组默认为 root toot

[root@test lib]# cd /usr/local/maven/
[root@test maven]# ls
apache-maven-3.6.1  repository
[root@test maven]# ll -a
total 0
drwxr-xr-x   4 root root  50 Aug  1 10:17 .
drwxr-xr-x. 16 root root 180 Aug  1 10:15 ..
drwxr-xr-x   6 root root  99 Aug  1 10:16 apache-maven-3.6.1
drwxr-xr-x   2 root root   6 Aug  1 10:17 repository

更改 repository 目录所属用户和组为 jenkins jenkins

chown -R jenkins:jenkins repository/
[root@test maven]# chown -R jenkins:jenkins repository/
[root@test maven]# ll -a
total 0
drwxr-xr-x   4 root    root     50 Aug  1 10:17 .
drwxr-xr-x. 16 root    root    180 Aug  1 10:15 ..
drwxr-xr-x   6 root    root     99 Aug  1 10:16 apache-maven-3.6.1
drwxr-xr-x   2 jenkins jenkins   6 Aug  1 10:17 repository

再次构建就能在maven本地仓库中创建jar包目录下载jar包了

可以在 /usr/local/maven/repository 仓库目录下看到 下载的jar包会对应的目录 及对应的用户组

 

 

 

 

 

 

 

 

AI 驱动代码审查实战

Claude code-review 插件深度解析,把 AI 智能审查接进 CI/CD 流水线

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wudinaniya

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值