yum安裝的Jenkins 配置文件默認位置/etc/sysconfig/jenkins
默認jenkins服務以jenkins用戶運行,這時在jenkins執行maven腳本時可能會發生沒有權限操作某個目錄下的文件,覆蓋文件等情況。例如可能會報下面的錯誤。
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.5.2:install (default-install) on project icps-parent: Failed to install artifact io.binghe:binghe-parent:pom:1.0.0-SNAPSHOT: /home/repository/io/binghe/binghe-parent/1.0.0-SNAPSHOT/binghe-parent-1.0.0-SNAPSHOT.pom (權限不夠) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
可以讓jenkins以root用戶運行來解決這個問題
1.將jenkins賬號分別加入到root組中
gpasswd -a jenkins root
2.修改/etc/sysconfig/jenkins文件中,
#user id to be invoked as (otherwise will run as root; not wise!)
JENKINS_USER=root
JENKINS_GROUP=root
可以修改為root權限運行
重啟服務,搞定。