詹金斯和 Git?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14841298/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jenkins and Git?
提问by techsjs2013
My firm right now is using Subversion and we have Jenkins pulling the SCM for changes and if anything changes it will do the Maven build.
我的公司现在正在使用 Subversion,我们让 Jenkins 拉取 SCM 进行更改,如果有任何更改,它将执行 Maven 构建。
We are moving to Git, but I don't see any way to pull a Git repository for changes... Am I missing something?
我们正在迁移到 Git,但我看不到任何方式来拉取 Git 存储库进行更改......我错过了什么吗?
回答by CIGuy
You can configure the Jenkins Git plugin to poll your repo for changes, but the recommended method is to add a post-receive (aka post-commit) hook to your repo. This way Jenkins is notified instantly on every commit.
您可以配置 Jenkins Git 插件来轮询您的 repo 以获取更改,但推荐的方法是向您的 repo 添加 post-receive(又名 post-commit)挂钩。这样,每次提交时都会立即通知 Jenkins。
You can read more here: https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin
您可以在此处阅读更多信息:https: //wiki.jenkins-ci.org/display/JENKINS/Git+Plugin
回答by Darren White
You may not have the Git plugin installed, which is why you can't see the options. You would never have had to do this for subversion as the plugin for that ships by default. You can either use the automatic installer supplied in Jenkins to install the plugin, or you can do it manually (useful if you are behind corporate firewall).
您可能没有安装 Git 插件,这就是您看不到选项的原因。您将永远不必为 subversion 执行此操作,因为默认情况下该插件随附。您可以使用 Jenkins 中提供的自动安装程序来安装插件,也可以手动安装(如果您位于公司防火墙后面,则很有用)。
Some useful links: The Git plugin: https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin
一些有用的链接:Git 插件:https: //wiki.jenkins-ci.org/display/JENKINS/Git+Plugin
The GitHub plugin: https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Plugin
GitHub 插件:https: //wiki.jenkins-ci.org/display/JENKINS/GitHub+Plugin
The Bitbucket plugin: https://wiki.jenkins-ci.org/display/JENKINS/Bitbucket+OAuth+Plugin
Bitbucket 插件:https: //wiki.jenkins-ci.org/display/JENKINS/Bitbucket+OAuth+Plugin
The Google Code plugin: https://wiki.jenkins-ci.org/display/JENKINS/Repo+Plugin
谷歌代码插件:https: //wiki.jenkins-ci.org/display/JENKINS/Repo+Plugin
The Git parameter plugin: https://wiki.jenkins-ci.org/display/JENKINS/Git+Parameter+Plugin
Git 参数插件:https: //wiki.jenkins-ci.org/display/JENKINS/Git+Parameter+Plugin
The GitLab hook plugin: https://wiki.jenkins-ci.org/display/JENKINS/Gitlab+Hook+Plugin
GitLab 钩子插件:https://wiki.jenkins-ci.org/display/JENKINS/Gitlab+Hook+Plugin
A big list of all plugins: https://wiki.jenkins-ci.org/display/JENKINS/Plugins#Plugins-Sourcecodemanagement
所有插件的大列表:https: //wiki.jenkins-ci.org/display/JENKINS/Plugins#Plugins-Sourcecodemanagement
CloudBeesprovides Jenkins continuous integration and Git hosting as a service - which might also help you http://www.cloudbees.com/#slide-2.
CloudBees提供 Jenkins 持续集成和 Git 托管即服务 - 这也可能对您有帮助http://www.cloudbees.com/#slide-2。
Good luck with your migration. We have found a few gotchas in the Maven release plugin when performing a similar migration - if I had to do it again I would make some pro-type releases beforehand.
祝您迁移顺利。在执行类似的迁移时,我们在 Maven 发布插件中发现了一些问题——如果我必须再次这样做,我会事先制作一些专业类型的版本。
回答by AniSaw
First you need to configure the Jenkins Git plugin which includes the Git client, Git hook up, etc. Then go to the GitHub account and navigate to
首先需要配置Jenkins Git插件,包括Git客户端、Git挂钩等,然后到GitHub账号导航到
Settings → Service Hooks → WebHook URLs.
设置 → 服务挂钩 → WebHook URL。
You need to provide a machine hostname on which Jenkins is running along with the Jenkins port number.
您需要提供运行 Jenkins 的机器主机名以及 Jenkins 端口号。
The WebHook URL is something like - http:// host_name:8080/github-webhook/ (where 8080 is a default Jenkins port)
WebHook URL 类似于 - http://host_name:8080/github-webhook/(其中 8080 是默认的 Jenkins 端口)
GitHub will hit these WebHook URLs with POST requests when you push the changes to GitHub, passing along information about the push.
当您将更改推送到 GitHub 时,GitHub 将使用 POST 请求访问这些 WebHook URL,并传递有关推送的信息。
There are some build triggers options provided by Jenkins and those are as following -
Jenkins 提供了一些构建触发器选项,如下所示 -
- Build when a change is pushed to GitHub.
- Poll SCM
- Build with some time interval
- etc...
- 在将更改推送到 GitHub 时构建。
- 轮询单片机
- 以一定的时间间隔构建
- 等等...
Choose the best suitable to your requirement.
选择最适合您的要求。
回答by Larry Shatzer
Jenkins has a Git Plugin, which contains lots of useful information you might be after. Hereis a post that might help you as well.
回答by Mahi
In order to use Git in Jenkins, the following two plugins need to be installed:
为了在Jenkins中使用Git,需要安装以下两个插件:
1. Git-Client-plugin
2. Git-plugin
The first plugin (Git-Client-plugin) is a low-level API to execute git operations (git add, git commit, git push ,git clone,..etc).
第一个插件 (Git-Client-plugin) 是一个低级 API,用于执行 git 操作(git add、git commit、git push、git clone 等)。
The second plugin (Git-plugin) adds Git as an SCM option for Jenkins jobs.
第二个插件 (Git-plugin) 添加 Git 作为 Jenkins 作业的 SCM 选项。
The second plugin relies on functionality from the first plugin, and so both must be present for Git to work with Jenkins.
第二个插件依赖于第一个插件的功能,因此两个插件都必须存在,Git 才能与 Jenkins 一起工作。