验证Jenkins CI Github私人存储库 [英] Authenticate Jenkins CI for Github private repository

查看:206
本文介绍了验证Jenkins CI Github私人存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让Jenkins自动地从我们在Github上托管的私人库中获取数据。
但是我不知道如何完成这个任务..试图文档,为jenkins用户生成ssh-key,我可以看到的是:无法克隆repo。我已检查过网址 - 它们是有效的。



任何线索,也许你知道一些文档/博客/什么描述这种东西?

解决方案

也许GitHub支持部署键是您要寻找的?引用此页:


我应何时使用部署密钥?



很简单,当你有一个服务器需要pull访问一个私人仓库。此密钥直接附加到存储库,而不是个人用户帐户。


如果这是你已经尝试,无法正常工作,您可能需要更新您的问题,并提供所使用的网址,关键文件的名称和位置等详细信息。






现在的技术部分:如何使用Jenkins的SSH密钥?



如果你有一个 jenkins unix用户,您可以将部署密钥存储在〜/ .ssh / id_rsa 中。当Jenkins尝试通过ssh克隆repo时,它将尝试使用该键。



在某些设置中,您不能将Jenkins作为自己的用户帐户运行,不能使用默认的ssh键位置〜/ .ssh / id_rsa 。在这种情况下,您可以在其他位置创建密钥,例如〜/ .ssh / deploy_key ,并配置 ssh 使用 /.ssh/config

 主机github-deploy-myproject 
HostName github。 com
用户git
IdentityFile〜/ .ssh / deploy_key
身份只是是

因为所有使用 git@github.com 对所有Github存储库进行身份验证,并且您不希望上述密钥用于您与Github的所有连接,创建了主机别名 github-deploy-myproject 。您的克隆网址现在变成了

  git clone github-deploy-myproject:myuser / myproject 



,这也是您在Jenkins中的存储库URL



(请注意,您必须不要 ssh:// 放在前面才能使用。)


I'd like for Jenkins to automagically fetch data from my private repository hosted on Github. But I have no idea how to accomplish that task.. Tried the documentation, generating ssh-key for jenkins user and all what I can see is: "unable to clone the repo". I've checked URLs - they are valid.

Any clues, maybe you know some docs/blogs/whatever which are describing this kind of stuff?

解决方案

Perhaps GitHub's support for deploy keys is what you're looking for? To quote that page:

When should I use a deploy key?

Simple, when you have a server that needs pull access to a single private repo. This key is attached directly to the repository instead of to a personal user account.

If that's what you're already trying and it doesn't work, you might want to update your question with more details of the URLs being used, the names and location of the key files, etc.


Now for the technical part: How to use your SSH key with Jenkins?

If you have, say, a jenkins unix user, you can store your deploy key in ~/.ssh/id_rsa. When Jenkins tries to clone the repo via ssh, it will try to use that key.

In some setups, you cannot run Jenkins as an own user account, and possibly also cannot use the default ssh key location ~/.ssh/id_rsa. In such cases, you can create a key in a different location, e.g. ~/.ssh/deploy_key, and configure ssh to use that with an entry in ~/.ssh/config:

Host github-deploy-myproject
    HostName       github.com
    User           git
    IdentityFile   ~/.ssh/deploy_key
    IdentitiesOnly yes

Because all you authenticate to all Github repositories using git@github.com and you don't want the above key to be used for all your connections to Github, we created a host alias github-deploy-myproject. Your clone URL now becomes

git clone github-deploy-myproject:myuser/myproject

and that is also what you put as repository URL into Jenkins.

(Note that you must not put ssh:// in front in order for this to work.)

这篇关于验证Jenkins CI Github私人存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆