amine al
amine al

Reputation: 11

hooking gitlab with jenkins

I'm trying to connect Gitlab CE 8.16 with Jenkins 2.46.1 using the GitLab hook plugin 1.4 to trigger builds when push or merge.

So I checked "Build when a change is pushed to GitLab", copied the GitLab CI Service URL: http://server:port/project/my-project and the security token, to gitlab webhook, disabled ssl verification and when I clicked on Test, I got this error :

Hook execution failed: execution expired

What am I doing wrong, please? How can I make it work?

Upvotes: 1

Views: 3857

Answers (3)

Vincent Gerris
Vincent Gerris

Reputation: 7508

There are a few things that are needed to make it work, there is documentation here: https://github.com/jenkinsci/gitlab-plugin#global-plugin-configuration

So:

  • Make sure the jenkins user that you use on the GitLab side has the proper permissions - it needs project access and the APITOKEN needs to be there
  • Create the webhook on the project in GitLab that corresponds to the project in Jenkins (the Jenkins project that uses the git repo you are working with)
  • In GitLab, when you create webhooks to trigger Jenkins jobs, use this format for the URL and do not enter anything for 'Secret Token': https://USERID:APITOKEN@JENKINS_URL/project/YOUR_JOB

You can use a non-https link too and skip SSL verification if the certificate is not valid. Either way, the gitlab server has to be able to connect to the name and port you are using there.

Hit test and it should work, if not, you might not be able to connect to the server. Make sure your Jenkins server is listening on the URL and port that you are using, the error seems to be related to that not being right.

It's possible that GitLab server is not allowed to connect to the internet, or to the network you have the Jenkins server on, or there might be a firewall blocking the port you try to connect to (80/443) on the local Jenkins machine.

Try to do for example a curl to the Jenkins server and see what comes back:

curl http://you.jenkins.fqdn/

If you don't get something like:

<html><head><meta http-equiv='refresh' content='1;url=/loginEntry?from=%2F'/><script>window.location.replace('/loginEntry?from=%2F');</script></head><body style='background-color:white; color:white;'>


Authentication required
<!--
You are authenticated as: anonymous
Groups that you are in:

Permission you need to have (but didn't): hudson.model.Hudson.Read
 ... which is implied by: hudson.security.Permission.GenericRead
 ... which is implied by: hudson.model.Hudson.Administer
-->

</body></html>

then you cannot connect. If it's not the Jenkins server where the issue is, you need to ask the network people that manage the server about it. Hope that helps, good luck!

Upvotes: 1

Josiah Perisho
Josiah Perisho

Reputation: 41

Here is what worked for me: Ensure there is a merge request, even if you don't intend to actually merge any branches.

Go to branches -> select 'merge request' for a branch to merge -> create the request

Now try to test the integration.

Upvotes: 0

VonC
VonC

Reputation: 1323115

Make sure to use the latest 1.4 GitLab hook plugin (1.4.3, March 2016)

Look into your GitLab production.log, as in this issue, and see if this is a proxy configuration problem.
You should at least the context of that error message.

Upvotes: 0

Related Questions