Jenkins:Slave没有使用项目配置中提供的SSH密钥来验证Git

时间:2018-06-05 13:16:51

标签: git jenkins ssh

我有一个(Linux)Jenkins master,其ssh密钥配置为' SSH用户名和私钥'使用Web界面直接输入。该密钥用于对Codebase上的Git进行身份验证,这在主节点上按预期工作。

现在要构建.NET应用程序,我已经创建了一个Windows从属节点,该节点也应该使用此密钥来克隆代码库中的repo,但看起来奴隶并没有使用密钥。所有导致身份验证失败。

在SCM下我有正确的URL和凭证,关键测试似乎没问题(因为它是主测试它)。运行我的构建项目时,我得到以下(审查)错误:

Started by user XXX
[EnvInject] - Loading node environment variables.
Building remotely on Windows Build Server (Windows) in workspace C:\Jenkins\workspace\XXX
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url git@codebasehq.com:XXX # timeout=10
Fetching upstream changes from git@codebasehq.com:XXX
> git --version # timeout=10
using GIT_SSH to set credentials 
> git fetch --tags --progress git@codebasehq.com:XXX +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from git@codebasehq.com:XXX
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:825)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1092)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1123)
    at org.jenkinsci.plugins.multiplescms.MultiSCM.checkout(MultiSCM.java:143)
    at hudson.scm.SCM.checkout(SCM.java:495)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1276)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:560)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:485)
    at hudson.model.Run.execute(Run.java:1735)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:405)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@codebasehq.com:XXX +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: XXX@codebasehq.com: Permission denied (publickey).
fatal: Could not read from remote repository.

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

我认为我不必自己将密钥复制到奴隶,因为这会使詹金斯的密钥提供者无用吗?欢迎任何帮助。提前谢谢。

ND

编辑:

将私钥从Jenkins GUI手动复制到从属节点上的id_rsa文件中,可以在直接在VM内部工作时进行克隆,但使用Jenkins构建仍然会产生相同的错误。还在寻找一个芒果。

0 个答案:

没有答案