Jenkins使用Git和Deploy Key构建

我将git插件添加到Jenkins。我已经在构建服务器上作为jenkins用户生成了一个公共密钥。我将此密钥作为部署密钥添加到github。我添加了带有詹金斯名称和email的全局git属性,并且该电子邮件与公钥末尾的内容匹配。

当詹金斯(Jenkins)尝试从git仓库(托管在Github上)中提取信息时,我得到以下信息:

Started by user anonymous

Building in workspace /var/lib/jenkins/jobs/Test Deployment/workspace

Checkout:workspace / /var/lib/jenkins/jobs/Test Deployment/workspace - hudson.remoting.LocalChannel@9ba3afe

Using strategy: Default

Cloning the remote Git repository

Cloning repository origin

ERROR: Error cloning remote repo 'origin' : Could not clone git@github.com:GenRocket/GenRocket.git

hudson.plugins.git.GitException: Could not clone git@github.com:GenRocket/GenRocket.git

at hudson.plugins.git.GitAPI.clone(GitAPI.java:245)

at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1121)

at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1063)

at hudson.FilePath.act(FilePath.java:839)

at hudson.FilePath.act(FilePath.java:821)

at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1063)

at hudson.model.AbstractProject.checkout(AbstractProject.java:1218)

at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:586)

at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:475)

at hudson.model.Run.run(Run.java:1438)

at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)

at hudson.model.ResourceController.execute(ResourceController.java:88)

at hudson.model.Executor.run(Executor.java:239)

Caused by: hudson.plugins.git.GitException: Command "git clone --progress -o origin git@github.com:GenRocket/GenRocket.git /var/lib/jenkins/jobs/Test Deployment/workspace" returned status code 128:

stdout: Cloning into /var/lib/jenkins/jobs/Test Deployment/workspace...

stderr: Host key verification failed.

fatal: The remote end hung up unexpectedly

不确定问题是什么,或者关于配置我忘记了要做什么。任何帮助表示赞赏。让我知道您是否需要更多详细信息。

回答:

尝试将github添加到jenkins用户的.ssh /

known_hosts文件中。如果您手动尝试以jenkins用户身份进行克隆,它会提示您将github.com添加为已知主机。一旦这样做,jenkins应该能够在进行构建时验证主机密钥。

以上是 Jenkins使用Git和Deploy Key构建 的全部内容, 来源链接: utcz.com/qa/418789.html

回到顶部