2

我通过在 /etc/sysconfig/hudson 中将配置更改为“HUDSON_USER=myuser”,以自定义用户身份运行 Hudson 服务(守护程序)。我已确认 SSH 服务器添加了 /home/myuser/.ssh 中的 RSA 密钥。

当我通过以“myuser”身份登录系统来运行 Hudson 时,它可以工作并且可以从 git 存储库中获取代码。

nohup java -jar hudson.war --httpPort=8081 > /home/myuser/hudson.out 2>&1 &

当我运行 Hudson 守护程序时,然后在运行构建时,我无法从 git 存储库中获取源代码,并显示以下日志并显示 Permission denied 错误。

Started by user anonymous
Checkout:workspace / /home/myuser/.hudson/jobs/test/workspace - hudson.remoting.LocalChannel@6083969e
Using strategy: Default
Last Built Revision: Revision a0d97d4d7bf5ee08124f76e5eb98bab354754cad (origin/master)
Checkout:workspace / /home/myuser/.hudson/jobs/test/workspace - hudson.remoting.LocalChannel@6083969e
Fetching changes from the remote Git repository
Fetching upstream changes from ssh://myuser@10.10.10.10:20/home/git-repos/test-proj.git
ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway
ha:AAAAWB+LCAAAAAAAAABb85aBtbiIQSmjNKU4P08vOT+vOD8nVc8DzHWtSE4tKMnMz/PLL0ldFVf2c+b/lb5MDAwVRQxSaBqcITRIIQMEMIIUFgAAckCEiWAAAAA=ERROR:  (Underlying report) : Error performing command: /usr/bin/git fetch -t ssh://myuser@10.10.10.10:20/home/git-repos/test-proj.git +refs/heads/*:refs/remotes/origin/*
Command "/usr/bin/git fetch -t ssh://myuser@10.10.10.10:20/home/git-repos/test-proj.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
fatal: The remote end hung up unexpectedly

ha:AAAAWB+LCAAAAAAAAABb85aBtbiIQSmjNKU4P08vOT+vOD8nVc8DzHWtSE4tKMnMz/PLL0ldFVf2c+b/lb5MDAwVRQxSaBqcITRIIQMEMIIUFgAAckCEiWAAAAA=ERROR: Could not fetch from any repository
ha:AAAAWB+LCAAAAAAAAABb85aBtbiIQSmjNKU4P08vOT+vOD8nVc8DzHWtSE4tKMnMz/PLL0ldFVf2c+b/lb5MDAwVRQxSaBqcITRIIQMEMIIUFgAAckCEiWAAAAA=FATAL: Could not fetch from any repository
ha:AAAAWB+LCAAAAAAAAABb85aBtbiIQSmjNKU4P08vOT+vOD8nVc8DzHWtSE4tKMnMz/PLL0ldFVf2c+b/lb5MDAwVRQxSaBqcITRIIQMEMIIUFgAAckCEiWAAAAA=hudson.plugins.git.GitException: Could not fetch from any repository
        at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:887)
        at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:845)
        at hudson.FilePath.act(FilePath.java:758)
        at hudson.FilePath.act(FilePath.java:740)
        at hudson.plugins.git.GitSCM.gerRevisionToBuild(GitSCM.java:845)
        at hudson.plugins.git.GitSCM.checkout(GitSCM.java:622)
        at hudson.model.AbstractProject.checkout(AbstractProject.java:1483)
        at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:507)
        at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:424)
        at hudson.model.Run.run(Run.java:1366)
        at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
        at hudson.model.ResourceController.execute(ResourceController.java:88)
        at hudson.model.Executor.run(Executor.java:145)
4

1 回答 1

2

我已将 RSA 密钥更改为无密码并添加到 Github 服务器。它解决了将 hudson 作为 init.d 服务运行时从 Git 获取源的问题。

此外,这就是我向 Github 添加密钥的方式,适用于正在搜索 HOW TO https://help.github.com/articles/generating-ssh-keys的任何人

于 2012-11-01T10:12:57.520 回答