How do I 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 Plug-in to your Jenkins installation.

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

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

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

  3. Click Advanced to see all the configuration fields.

  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.

  1. Copy and adapt as needed the following payload into the Request body field. For more details on the payload fields, see how do I push custom events from 3rd party systems?
{ 
  "eventType": "CUSTOM_DEPLOYMENT",
  "attachRules": { 
    "tagRule" : {
        "meTypes" : "HOST",
        "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}"
  }
}

Note: ${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.