Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Excerpt

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

Table of Contents
maxLevel1
excludePlugin Information
printablefalse

Why?

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

Code Block
http://yourserver/jenkins/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:

Code Block
http://yourserver/jenkins/gitlab/build_now

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

Notes:

  • 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

Notify commit hook

Add this web hook on your Gitlab project:

Code Block
http://yourserver/jenkins/gitlab/notify_commit

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

Dependencies