3
votes

I want to begin Jenkins build automatically after commit to GitLab (git panel).

So I've setup this plugin https://wiki.jenkins-ci.org/display/JENKINS/Build+Token+Root+Plugin and configured it:

enter image description here

Then I`ve added webhook to GitLab:

enter image description here

Now I can launch Jenkins task via http-request (from browser for example) but w/o success from Gitlab (via button "Test Hook"). Why?

Is webhook of GitLab not the same as http-request?

I can autolaunch of this Jenkins job via https://wiki.jenkins-ci.org/display/JENKINS/Gitlab+Hook+Plugin but cant, due to restrictions of standard git plugin of Jenkins.

1
Looks that this is problem with authorization.ipeacocks

1 Answers

5
votes

You say that you've configured the Build Token Root Plugin, but your webhook URL ends with /build?token=test.

Though if you read the plugin documentation, it says:

This plugin offers an alternate URI pattern which is not subject to the usual overall or job read permissions. Just ping buildByToken/build?job=NAME&token=SECRET.

The URL you're using won't work in a Jenkins setup with authentication — hence why the Build Token Root Plugin exists — you need to use that plugin's URL pattern.

i.e. in your case it should be something like:
https://jenkins.example.com/buildByToken/build?job=Config+Generator+Launch+UAT+PP+PROD&token=test

It seems a bit weird to me that you have two levels of /job/ in the job name, but maybe you're using the folders plugin or something? So maybe the job parameter will have to be Configuration+Delivery/job/Config+Generator+Launch+UAT+PP+PROD or so.

In any case, you can play around by calling those URLs directly from your browser, rather than having to change the GitLab hook URL and hitting Test Hook every time.