'403: No valid crumb' Jenkins GitHub webhook error fix

Fix Jenkins GitHub ‘valid crumb’ errors

A common problem DevOps professionals hit when trying to configure a GitHub webhook to remotely invoke a Jenkins build job is the dreaded 403: No valid crumb was included in the request error. Thankfully, there’s a pretty straight forward fix to the problem.

This error is typically caused by using the Jenkins remote build trigger URL on the Jenkins webhook, rather than using the github-webhook URI that is configured as part of the Jenkins GitHub plugin.

If you want a GitHub webhook to trigger a Jenkins build without a 403 no valid crumb error, the Jenkins plugin must be used.

403 no valid crumb error

There’s an easy fix to the GitHub to Jenkins 403: no valid crumb error

403: No valid crumb fix

To avoid a 403 error when integrating Jenkins and GitHub, follow these three steps when you create the build job and configure the webhook:

  1. Make sure the Jenkins GitHub plugin is installed in Jenkins
  2. In your Jenkins build job click the GitHub hook trigger for GITScm polling checkbox
    1. Do not choose the Trigger builds remotely option
  3. Create  a Jenkins API for the user with rights to run the build job
  4. In GitHub, create a webhook to trigger the Jenkins GitHub plugin
  5. Set the GitHub payload as <JENKINS_URL> /github-webhook/
  6. Set the Jenkins API Token as the webhook’s secret token
  7. Save the GitHub webhook configuration and watch Jenkins builds run without 403 no crumb errors
GitHub Jenkins WebHook

The GitHub hook trigger must be used to avoid 403 no crumb in request errors from Jenkins.

Jenkins tokens and Webhook secrets

The Webhook secret used by GitHub is created as an API token in Jenkins for a user who has rights to invoke the build job.

GitHub webhook secret

The Jenkins API token is used as the GitHub webhook secret.

Do not use the remote URL Jenkins provides for invoking builds remotely from scripts or external programs. Instead, use the Jenkins server’s IP address or domain name with /github-webhook/ appended to it.

Your intro to GitHub Actions training course

Here’s how to get started with GitHub Actions:

Follow these tutorials and you’ll learn GitHub Actions fast.

GitHub webhook to Jenkins

GitHub webhook configuration in GitHub.

With the GitHub webhook to Jenkins configured as a trigger, push commits to your GitHub repository at will. The GitHub server will then invoke our Jenkins instance and your continuous integration build jobs will run.

If you follow these steps, your Jenkins Git and GitHub webhook will run successfully without any 403 no crumb in the request errors slowing you down.

App Architecture
Software Quality
Cloud Computing