Contents

Graylog Notification Trigger a Jenkins Build

A short guide on how to get Graylog notification to trigger a Jenkins build.

 Intro

I didnt find anything online on how to trigger a jenkins build through Graylog Notification. Here is a step-by-step method to do exactly that.

 Prerequisites

You must be on Graylog 6 or higher. 5.X and below versions are not supported. This is because “HTTP Notification” option in older versions of Graylog only support POST method whereas we need to use GET when making HTTP request to Jenkins.

 Jenkins Setup

Create Jenkins API Token

In the top right corner of Jenkins, click your username and select Security.

Under API Token, click Add new Token button. Give it a name and select Generate button. Note down the token that was generated.

/posts/graylogtriggerjenkinsbuild/image1.png
Create Jenkins API Token

Modify Jenkins Project

For the Jenkins project you’re wanting to trigger, go to its Configuration page. Under Triggers, check Trigger builds remotely (e.g., from scripts). Enter a string here that we will use later, in this example, we will use myspecialtokentext.

/posts/graylogtriggerjenkinsbuild/image2.png
Enable Authentication Token

 Graylog Setup

In Graylog, go to Alerts > Notifications > Create Notification.

Give it a title. Select Custom HTTP Notification for Notification Type. If you dont see it then you likely skipped over the Prerequisites section of this post!

URL: This will be your Jenkins job URL + /build + ?token=myspecialtokentext or whatever token text you specified in the steps above. You may receive a warning about adding the URL to whitelist, go ahead and do that.

  • Example: https://jenkins.example.com/job/Misc/job/test%20job/build?token=myspecialtokentext

Skip TLS verification: Check it if your certificate isnt trusted.

Basic authentication: Here you will enter your jenkins account followed by : (colon) and then your token you generated under Jenkins user settings. Format: username:token

  • Example: admin:1116784c02a092c5bcbf20a22e6cabadfe

HTTP Method: GET

/posts/graylogtriggerjenkinsbuild/image3.png
Example of Graylog Notification setup

Click Execute Test Notification, if all was correct, your Jenkins build should start.