Dependencies Link to heading

Create Jenkins User Link to heading

Login as admin > Manage Jenkins > Manage Users > Create User

Fill in the information for your user and click the “Create User”.

Enable Permissions for User Link to heading

Go to Manage Jenkins > Configure Global Security

Set Authorization to “Anyone can do anything” if you are the only user.

Otherwise, if you want to control permissions, select Matrix-Based Security.

The new user needs the following permissions:

  • Overall: Read
  • Job: Build, Read & Workspace

Create Job and Auth Token Link to heading

Go to New Item > Freestyle project

Under Build Triggers, select “Trigger Builds Remotely”.

Generate a random string (letters and numbers only) and enter it as your token.

Fill out the rest of the job and Save.

Create the User’s API Token Link to heading

Logout of Jenkins and log back in as your new user.

Click the username dropdown at the top right and select “configure”.

Under “API Token” click “Add New Token”, enter a name and generate.

Copy and save the token provided.

Create URL Link to heading

We now have all the information to create the URL:

http://<username>:<api_token>@<jenkins_hostname>/job/<job_name>/build?token=<auth_token>
  • <username> = new jenkins user
  • <api_token> = user’s api token
  • <jenkins_hostname> = the domain of your jenkins server (i.e. jenkins.domain.com or jenkins.domain.com:8080)
  • <job_name> = the name of the job to run
  • <auth_token> = the job’s authorization token

Test The URL Link to heading

In the Jenkins job, under Build, enter a harmless command like so:

#!/bin/bash
touch /var/lib/jenkins/test.txt

Then do a HTTP POST request to that domain and check in Jenkins if the job was built:

curl -X POST <url>

Create Webhook in DataDog Link to heading

We need to create a webhook in DataDog to trigger Jenkins with the url we created.

Login to DataDog > Integrations > Webhooks

At the bottom of the window next to “Webhooks” click “New +”

Enter a name for the webhook, enter the jenkins url under “URL” and save. You can leave the payload as default.

Trigger Webhook from Monitor Link to heading

To trigger the webhook, create a monitor and add the line below to the message with the relevant <webhook_name>:

@webhook-<webhook_name>

This will send in an HTTP request to the Jenkins webhook URL when the monitor is triggered resulting in the Jenkins job being built.