Push deployment events from Jenkins

To configure Jenkins to push deployment events to Dynatrace.

  1. Generate a new access token for the Dynatrace API.

  2. Install the HTTP Request Plugin to your Jenkins installation.

  3. In the Jenkins build configuration, click Add build step and select HTTP Request.

Jenkins - add HTTP Request as build step

  1. In the URL field, type in the URL of your event API endpoint:

    • Dynatrace Managed https://{your-domain}/e/{your-environment-id}/api/v1/events/
    • Dynatrace SaaS https://{your-environment-id}.live.dynatrace.com/api/v1/events/
    • Environment ActiveGate https://{your-activegate-domain}/e/{your-environment-id}/api/v1/events
  2. Select POST as the HTTP mode.

  3. Click Advanced to see all the configuration fields.

Jenkins - HTTP Request configuration

  1. In the Headers section, select APPLICATION_JSON in the field Accept .

  2. Select APPLICATION_JSON in the field Content-type.

  3. Add a Custom header, type in Authorization in the Header field and Api-Token {token} in the Value field.

Jenkins - Headers configuration

  1. Copy and adapt as needed the following payload into the Request body field. For more details on the payload fields, see POST events.
{
"eventType": "CUSTOM_DEPLOYMENT",
"attachRules": {
"tagRule": {
"meTypes": "PROCESS_GROUP_INSTANCE",
"tags": "Dev"
}
},
"deploymentName": "${JOB_NAME}",
"deploymentVersion": "1.1",
"deploymentProject": "CustomBankingService",
"remediationAction": "http://revertMe",
"ciBackLink": "${BUILD_URL}",
"source": "Jenkins",
"customProperties": {
"Jenkins Build Number": "${BUILD_ID}",
"Git commit": "${GIT_COMMIT}"
}
}

${JOB_NAME}, ${BUILD_URL}, ${BUILD_ID}, ${GIT_COMMIT} are environment variables set by Jenkins during job execution.

  1. Save the build configuration. Next time you build your project, the deployment event will be pushed to the monitored entities (for example, hosts and services) you have defined in the tagRule of the request body.