1

This seems to be a very simple problem, but I have yet found a solution that works. Basically I created a web hook from Gitlab to trigger a build in Jenkins for every commit. However, Jenkins want the web hook request with a GET method, and Gitlab web hook makes a request with a POST method. Is there anyway to work around this problem?

From the search I've done, it seems Jenkins used to want a POST request, but it is no longer the case. I am using Jenkins 1.610 with Gitlab 7.9.4.

Nakilon
  • 34,866
  • 14
  • 107
  • 142
Khanetor
  • 11,595
  • 8
  • 40
  • 76
  • What address are you sending the webhook to? The `/git/notifyCommit` endpoint accepts POST requests. Have you tried the GitLab plugins for Jenkins? – Christopher Orr Apr 23 '15 at 11:51
  • I just check with the /git/notifyCommit endpoint and it does not accept POST request. It does accept GET however. I tried GitLab plugins, but I cannot set the authentication token correctly, and because of that, I cannot even access my job configuration :( – Khanetor Apr 23 '15 at 16:27
  • The `/git/notifyCommit` endpoint does accept POST requests. You can see it working here: `curl -v -X POST https://ci.jenkins-ci.org/git/notifyCommit?url=git@github.com:jenkinsci/jenkins.git` – Christopher Orr Apr 23 '15 at 20:03

3 Answers3

2

It turns out that because I enabled CSRF protection, any non-GET request to Jenkins is rejected. Disable CSRF, and I can trigger Jenkins with POST request.

Khanetor
  • 11,595
  • 8
  • 40
  • 76
0

Did you try this?

GitLab can be configured to interact with Jenkins

Anuja Lamahewa
  • 897
  • 1
  • 11
  • 23
0

I made a solution of my own in NodeJS. It's pretty much a hack that capture a web hook POST request from Gitlab, and forward that request to Jenkins as GET request.

Here is the code: http://git.myladybug.co/khanetor/githook-jenkins-trigger.git

I made 2 versions, the first one will want you to include project name and token in your string query. The second one will simply pass whatever url you have to Jenkins and return the response from Jenkins.

Khanetor
  • 11,595
  • 8
  • 40
  • 76