0914-Jenkins yum安装默认jenkins用户权限问题 导致maven编译权限错误 (Permission denied)
问题jenkins部署项目maven编译时报错Parsing POMsFailed 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/...
·
问题
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] ------------------------------------------------------------------------
更多推荐
已为社区贡献2条内容
所有评论(0)