Jenkins尝试从tomcat root构建,而不是JENKINS_HOME

时间:2016-10-19 03:46:30

标签: git tomcat jenkins

我最近将我的Jenkins安装从独立配置移动到Tomcat内,并且在尝试运行管道构建时,它在初始Git Checkout阶段失败(如下面的shell输出中所示)它尝试从家中初始化我的Ubuntu VM上的Tomcat目录(/ usr / share / tomcat7),而不是已定义的JENKINS_HOME(在本例中为/ var / lib / jenkins)。

Started by user joel
[Pipeline] node
Running on master in /var/lib/jenkins/jobs/mediawiki/workspace
[Pipeline] {
[Pipeline] echo
Beginning Wiki build process
[Pipeline] git
 > /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > /usr/bin/git config remote.origin.url git@bitbucket.org:ghostfreeman/lpg_mediawiki.git # timeout=10
Fetching upstream changes from git@bitbucket.org:ghostfreeman/lpg_mediawiki.git
 > /usr/bin/git --version # timeout=10
using GIT_SSH to set credentials Key
 > /usr/bin/git fetch --tags --progress git@bitbucket.org:ghostfreeman/lpg_mediawiki.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from git@bitbucket.org:ghostfreeman/lpg_mediawiki.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:797)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1051)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1082)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:109)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:83)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:73)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:52)
    at hudson.security.ACL.impersonate(ACL.java:221)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:49)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git fetch --tags --progress git@bitbucket.org:ghostfreeman/lpg_mediawiki.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: Could not create directory '/usr/share/tomcat7/.ssh'.
Failed to add the host to the list of known hosts (/usr/share/tomcat7/.ssh/known_hosts).
conq: repository does not exist.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1752)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1495)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:64)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:315)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:795)
    ... 13 more
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: null
Finished: FAILURE

Tomcat主目录仅限于root访问权限,我确信这是设计使然。我更喜欢在JENKINS_HOME中从项目的build / workspace目录执行的操作。我已将Tomcat配置为将JENKINS_HOME定义到我已定义构建和工作空间的目录,但由于对我来说不明显的原因,它会被忽略。我是否想念在Tomcat上设置Jenkins的东西?

1 个答案:

答案 0 :(得分:0)

我能够通过在tomcat home目录中创建所需的.ssh目录来解决问题,并在系统上为Tomcat用户分配访问角色。所有构建过程都按照预期在JENKINS_HOME中继续运行。