GitHub与Jenkins的集成 [英] GitHub integration with Jenkins

查看:125
本文介绍了GitHub与Jenkins的集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将Jenkins与GitHub集成有多种方法

There are multiple approaches in integrating Jenkins with GitHub

方法1)通过将Jenkins中生成的公钥文件复制到GitHub帐户,启用GitHub和Jenkins之间的ssh通信.这是一项任务.

Approach 1) Enable ssh communication between GitHub and Jenkins by copying public key file generated in Jenkins to GitHub account. This is one time task.

对于任何管道,请使用任何GitHub网址(例如ssh://git@github.com/account/repo.git),并使用Gi​​thub插件添加相应的管道配置

For any pipeline take any GitHub url(say ssh://git@github.com/account/repo.git) and add using Github plugin for that respective pipeline cocnfiguration

因此,Jenkins文件只需要checkout SCM即可结帐

So, Jenkins file just need to have checkout SCM to checkout

方法2)通过生成令牌为每个新仓库添加webhook来启用https通信,并在GitHub和Jenkins之间启用https通讯.但是,对于在GitHub中创建的每个新存储库,都应重复使用这种方法.

Approach 2) Enable https communication by adding webhook for every new repo by generating token and enable https comunication between GitHub and Jenkins. But this approach should be repeated for every new repo created in GitHub.

我们正在生产中使用GitHub存储库...

We are using GitHub repo... in production

在生产环境中,GitHub与Jenkins集成的最佳实践是什么?

Which is the best practice of GitHub integration with Jenkins in production?

推荐答案

基本上两者都是两件事.

Both are basically two different things.

第一种方法允许您设置凭证以使用Jenkins检出并将源代码推送到GitHub.第二种方法使您可以在存储库中检测到更改时设置自动构建触发器.

The first approach lets you set up credentials to checkout and push source code to GitHub using Jenkins. The second approach lets you set up automated build triggers when a change is detected in the repository.

总而言之,第一个是构建获取源代码所必需的,而第二个是可选的,因为您可以手动触发构建,尽管代码推送的自动触发是持续集成所固有的.另外,您不必为每个存储库单独添加webhooks.而是在组织级别添加一次,以覆盖该组织中的所有存储库,包括任何新添加的内容.

In summary, the first is mandatory for a build to get the source code, while the second is optional as you can trigger builds manually as well, although automated triggers on code push are inherent to continuous integration. Also, you need not add webhooks individually for every repository. Rather, add it once at the organization level to have all the repositories in that organization covered including any new additions.

这篇关于GitHub与Jenkins的集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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