【问题标题】:Jenkins attempts to build from tomcat root, and not JENKINS_HOMEJenkins 尝试从 tomcat 根目录构建,而不是 JENKINS_HOME
【发布时间】:2016-10-19 03:46:30
【问题描述】:

我最近将我的 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 时是否遗漏了什么?

【问题讨论】:

    标签: git tomcat jenkins


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-03
      • 2015-11-29
      • 2015-02-07
      • 1970-01-01
      相关资源
      最近更新 更多