0914-Jenkins yum安装默认jenkins用户权限问题 导致maven编译权限错误 (Permission denied)

问题

jenkins部署项目maven编译时报错

Parsing POMs
Failed to transfer Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.0.3.RELEASE from/to AliMaven (http://maven.aliyun.com/nexus/content/groups/public/): /root/mavenRepo/org/springframework/boot/spring-boot-starter-parent/2.0.3.RELEASE/spring-boot-starter-parent-2.0.3.RELEASE.pom.part.lock (Permission denied)
ERROR: Failed to parse POMs
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.0.3.RELEASE from/to AliMaven (http://maven.aliyun.com/nexus/content/groups/public/): /root/mavenRepo/org/springframework/boot/spring-boot-starter-parent/2.0.3.RELEASE/spring-boot-starter-parent-2.0.3.RELEASE.pom.part.lock (Permission denied) and 'parent.relativePath' points at no local POM @ line 14, column 13

	at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:364)
	at hudson.maven.MavenEmbedder.buildProjects(MavenEmbedder.java:361)
	at hudson.maven.MavenEmbedder.readProjects(MavenEmbedder.java:331)
	at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1328)
	at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1125)
	at hudson.FilePath.act(FilePath.java:1077)
	at hudson.FilePath.act(FilePath.java:1060)
	at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.parsePoms(MavenModuleSetBuild.java:986)
	at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:691)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
	at hudson.model.Run.execute(Run.java:1815)
	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)

分析

相同mvn命令,本地编译异常,通过jenkins编译报错,定位是用户权限问题

在shell中添加whoami打印jenkins用的是jenkins用户

jenkins是通过yum安装时自动创建的系统用户(没有目录,没有配置文件),无法通过su命令切换

要么改成root或其他用户,要么将mvn相关目录所有者改为jenkins(实测无效,可能时因为jenkins不是普通用户,无配置)

解决办法

将jenkins默认用户改为root或其他

//修改用户为root或其他
vim /etc/sysconfig/jenkins

 

//重启jenkins
systemctl restart jenkins

 

修改后编译成功!

[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ wechatmeeting ---
[INFO] Installing /var/lib/jenkins/workspace/microHomeSite/target/wechatmeeting-0.0.1-SNAPSHOT.jar to /root/mavenRepo/com/mircoptech/wechatmeeting/0.0.1-SNAPSHOT/wechatmeeting-0.0.1-SNAPSHOT.jar
[INFO] Installing /var/lib/jenkins/workspace/microHomeSite/pom.xml to /root/mavenRepo/com/mircoptech/wechatmeeting/0.0.1-SNAPSHOT/wechatmeeting-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.919s
[INFO] Finished at: Fri Sep 14 17:41:41 CST 2018
[INFO] Final Memory: 38M/465M
[INFO] ------------------------------------------------------------------------

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值