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

标签 git tomcat jenkins

我最近将我的 Jenkins 安装从独立配置移动到 Tomcat 中,并且在尝试运行管道构建时,它在初始 Git Checkout 阶段失败(如下面的 shell 输出中所示)它尝试从主页初始化我的 Ubuntu VM (/usr/share/tomcat7) 上的 Tomcat 目录,而不是定义的 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 中项目的构建/工作区目录执行的操作。我已将 Tomcat 配置为将 JENKINS_HOME 定义到我已定义构建和工作区的目录,但由于对我来说不明显的原因,它会被忽略。在 Tomcat 上设置 Jenkins 时我是否遗漏了什么?

最佳答案

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

关于git - Jenkins 尝试从 tomcat root 构建,而不是 JENKINS_HOME,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40121753/

相关文章:

windows - 有什么办法可以半自动提交吗?

jenkins - 使用分支参数构建管道

git - TeamCity 将功能分支推送到 master 分支

jenkins - 由 package.json 为 TestCafe 安装的 NPM browserstack 别名无法识别

git - 为什么我需要 SSH 授权才能克隆公开可用的 Git 存储库?

android - 如何在 Gradle 中编译 fork 库?

git - 你如何让 git diff 在 OS X 上使用 gitx --diff

jquery - 页面刷新在 Firefox 中不起作用

java - Tomcat启动失败,服务器8080端口已被占用

mysql - android中的tomcat apache+mysql连接