Languages

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

6 points
Asked by:
Root-ssh
177200

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?

2 answers
8 points
Answered by:
Root-ssh
177200

Found solution by myself.

It 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
2 comments
Zahid Asim
Hi &#64;Root-ssh - I am having same problem as you mentioned. I am not understanding this point 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 Can you please mention how to change /job/... to /project/....please? I didn&#39;t find any setting where I can instruct Jenkins to not use /job/ identifier and use /project/ in jobs URL?
ASSASSIN999
You can open Jenkins Job Settings, activate checkbox &#34;Build when a change is pushed to GitLab&#34; and then you will see actual GitLab webhook URL with &#34;project&#34; in path
Add comment
0 points
Answered by:
Root-ssh
177200

Thanks for your help!

0 comments Add comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
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