Gitlab Hook Plugin

Skip to end of metadata
Go to start of metadata

Plugin Information

Plugin ID gitlab-hook Changes In Latest Release
Since Latest Release
Latest Release
Latest Release Date
Required Core
Sep 02, 2013
[ruby-runtime|n/a] (version:0.12)
git (version:1.1.26)
Source Code
Issue Tracking
Open Issues
n/a (id: elvanja)
Usage Installations 2013-Apr 514
2013-May 582
2013-Jun 488
2013-Jul 567
2013-Aug 675
2013-Sep 770
2013-Oct 908
2013-Nov 967
2013-Dec 1032
2014-Jan 1142
2014-Feb 1255
2014-Mar 1390

Enables Gitlab web hooks to be used to trigger SMC polling on Gitlab projects


For Gitlab there is an existing solution that might work for you.
You can just use the notifyCommit hook on Git plugin like this:

http://your-jenkins-server/git/notifyCommit?url=<URL of the Git repository for the Gitlab project>

But, with a large number of projects that are mostly polling (no hooks), the project might actually be built with a great delay (5 to 20 minutes).
You can find more details about notifyCommit and this issue here.

That is where this plugin comes in.
It gives you the option to use build_now or notify_commit hook, whichever suits your needs better.

Build now hook

Add this web hook on your Gitlab project:


Plugin will parse the Gitlab payload and extract the branch for which the commit is being pushed and changes made.
It will then scan all Git projects in Jenkins and start the build for those that:

  • match url of the Gitlab repo
  • match committed Gitlab branch


  • for branch comparison, it will take into account both the branch definition and the strategy (this is different from the original notifyCommit)
  • the project must be enabled
  • you don't have to setup polling for the project

Parametrized projects

Plugin will recognize projects that are parametrized and will use the default parameter values for the build. In case you define a parameter inside the branch specifier, plugin will replace the parameter value with the commit branch from the payload. Replacing is done by matching ${PARAMETER_KEY} in branch specifier to the parameter list for the project.

Notify commit hook

Add this web hook on your Gitlab project:


The procedure is the same as for the build now hook, the difference is that this hook schedules polling of the project, much like the original notifyCommit.

Additional notes:

  • the project must be configured not to skip notifyCommit
  • parametrized projects can be polled, but subsequent build will use the default parametere values (can't propagate the branch to the polling)

Delete branch commits

In case Gitlab is triggering the deletion of a branch, the plugin will skip processing entirely.

Hook data related

Gitlab uses JSON POST to send the information to the defined hook.
The plugin expects the request to have the appropriate structure, like this example:

        :before => "95790bf891e76fee5e1747ab589903a6a1f80f22",
         :after => "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
           :ref => "refs/heads/master",
       :user_id => 4,
     :user_name => "John Smith",
    :repository => {
               :name => "Diaspora",
                :url => "localhost/diaspora",
        :description => "",
           :homepage => "localhost/diaspora",
            :private => true
       :commits => [
        [0] {
                   :id => "450d0de7532f8b663b9c5cce183b...",
              :message => "Update Catalan translation to e38cb41.",
            :timestamp => "2011-12-12T14:27:31+02:00",
                  :url => "http://localhost/diaspora/commits/450d0de7532f...",
               :author => {
                 :name => "Jordi Mallach",
                :email => ""


        [3] {
                   :id => "da1560886d4f094c3e6c9ef40349...",
              :message => "fixed readme",
            :timestamp => "2012-01-03T23:36:29+02:00",
                  :url => "http://localhost/diaspora/commits/da1560886d...",
               :author => {
                 :name => "gitlab dev user",
                :email => "gitlabdev@dv6700.(none)"
   total_commits_count => 3



In case you might wan't to inspect hook triggering (e.g. to check payload data), you can setup logging in Jenkins as usual. Just add a new logger for Class (this is because of JRuby internals).


plugin-scm-related plugin-scm-related Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Add Comment