Trigger Jenkins Job via Webhook and Bypass SSO

February 22, 2024

The Problem

Recently, I was attempting to trigger a Jenkins job via webhook (just like the UI tells you is possible).  Unfortunately, even with the authorization token, my request would be 401'd (unauthorized) and sent over to single sign-on.  I am shocked that there is no way to bypass SSO login when calling a webhook and providing an authorization token.

The Solution

Thankfully, there is a way!

  1. Login to your Jenkins instance as an admin.
  2. Install the Build Authorization Token Root plugin found here.
  3. Once installed, browse to the Jenkins job that you wish to trigger via a webhook.
  4. Click Configure.
  5. Under Build Triggers, check the Trigger Builds Remotely checkbox.
  6. Set an authentication token here.
  7. Save the job.
  8. You can now kick off your job with the following URL: 
    https://<Jenkins host>/buildByToken/build?job=<job name>&token=<token from step 6>
If your job name has spaces in it, replace those spaces with %20.

©2024 Tyler Wright