Languages

Gitlab + Jenkins - how to fix Error 403 No valid crumb was included in the request?

6 points
Asked by:
Root-ssh
94100

I try to connect Gitlab merge request webook with Jenkins and I got an error:

Error 403 No valid crumb was included in the request
HTTP ERROR 403
Problem accessing /view/test-view/job/test-project. Reason:
No valid crumb was included in the request

What I want to achieve?

  1. I try to use Gitlab Webhooks to trigger jenkins build when new merge request is created.
  2. When jenkins build triggered by gitlab merge request webhook succeed then merge request from feature branch to master will be possible.

Everything seems fine, but I get this error when I test the merge request webhook.

What steps I've done already:

1. I've opened -> Gitlab -> my project -> Settings -> Webhooks

2. I set: URL, Secret Token and clicked on 'Add webhook' button

  • URL - url to my project on jenkins:
    http://127.0.0.1:8080/job/user-test-repo/
  • Secret Token (generated secret token in jenkins project view - this plugin is required https://plugins.jenkins.io/gitlab-plugin/)

Entire response that I get in Gitlab:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 403 No valid crumb was included in the request</title>
</head>
<body><h2>HTTP ERROR 403</h2>
<p>Problem accessing /view/test-view/job/test-project. Reason:
<pre>    No valid crumb was included in the request</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.z-SNAPSHOT</a><hr/>

</body>
</html>

How to fix this problem?

1 answer
6 points
Answered by:
Root-ssh
94100

Found solution by myself.

I was pretty simple.

I needed to modify URL from /job/ to /project/ from:

http://127.0.0.1:8080/job/user-test-repo

to:

http://127.0.0.1:8080/project/user-test-repo

After we install jenkins gitlab plugin:

This plugin has it's own REST API which is integrated with jenkins. And this REST API looks like this:

https://JENKINS_URL/project/YOUR_JOB

We can read more here: 

Configuring per-project authentication

If you want to create separate authentication credentials for each Jenkins job:

  1. In the configuration of your Jenkins job, in the GitLab configuration section, click 'Advanced'
  2. Click the 'Generate' button under the 'Secret Token' field
  3. Copy the resulting token, and save the job configuration
  4. In GitLab, create a webhook for your project, enter the trigger URL (e.g. https://JENKINS_URL/project/YOUR_JOB) and paste the token in the Secret Token field
  5. After you add the webhook, click the 'Test' button, and it should succeed
0 comments Add comment
Native Advertising
­čÜÇ
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

ÔŁĄ´ŞĆ­čĺ╗ ­čÖé

Join