18

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.

We are moving to Git, but I don't see any way to pull a Git repository for changes... Am I missing something?

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
techsjs2013
  • 2,529
  • 3
  • 18
  • 24
  • I don't know the details with Jenkins. But of course this is possible, normally CI system use Git hooks to trigger an action, maybe this can help you complete a research with the keyword. – Simon Boudrias Feb 12 '13 at 20:35
  • possible duplicate of [How can I make Jenkins CI with git trigger on pushes to master?](http://stackoverflow.com/questions/5784329/how-can-i-make-jenkins-ci-with-git-trigger-on-pushes-to-master) – CharlesB Feb 12 '13 at 21:26
  • @CharlesB Not a duplicate, that question is specific to triggering for one branch only. – CIGuy Feb 12 '13 at 22:41
  • not a dup... I dont see any Git Plug-in – techsjs2013 Feb 13 '13 at 00:10

5 Answers5

24

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.

You can read more here: https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin

CIGuy
  • 4,926
  • 26
  • 37
10

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).

Some useful links: The Git plugin: https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin

The GitHub plugin: https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Plugin

The Bitbucket plugin: https://wiki.jenkins-ci.org/display/JENKINS/Bitbucket+OAuth+Plugin

The Google Code plugin: https://wiki.jenkins-ci.org/display/JENKINS/Repo+Plugin

The Git parameter plugin: https://wiki.jenkins-ci.org/display/JENKINS/Git+Parameter+Plugin

The GitLab hook plugin: 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

CloudBees provides Jenkins continuous integration and Git hosting as a service - which might also help you 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.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Darren White
  • 525
  • 5
  • 13
8

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

Settings → Service Hooks → WebHook URLs.

You need to provide a machine hostname on which Jenkins is running along with the Jenkins port number.

The WebHook URL is something like - http:// host_name:8080/github-webhook/ (where 8080 is a default Jenkins port)

GitHub will hit these WebHook URLs with POST requests when you push the changes to GitHub, passing along information about the push.

There are some build triggers options provided by Jenkins and those are as following -

  1. Build when a change is pushed to GitHub.
  2. Poll SCM
  3. Build with some time interval
  4. etc...

Choose the best suitable to your requirement.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
AniSaw
  • 193
  • 3
  • 9
1

Jenkins has a Git Plugin, which contains lots of useful information you might be after. Here is a post that might help you as well.

Larry Shatzer
  • 3,329
  • 8
  • 27
  • 35
1

In order to use Git in Jenkins, the following two plugins need to be installed:

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).

The second plugin (Git-plugin) adds Git as an SCM option for Jenkins jobs.

The second plugin relies on functionality from the first plugin, and so both must be present for Git to work with Jenkins.

Mahi
  • 1,060
  • 1
  • 10
  • 23