Deployment Change Tracking

Jenkins + Alert24: Log Deployments to Your Change Log

Log Jenkins deployments to Alert24 using a declarative pipeline post block or freestyle shell step. Works with HTTP Request Plugin and plain curl.

Jenkins supports post-build actions and declarative pipeline post blocks that run after a deployment stage completes. Use either approach to log changes to Alert24.

Before you start

You'll need:

  • An Alert24 API key with write scope, stored as a Jenkins credential (type: Secret text, ID: alert24-api-key)
  • Jenkins with the HTTP Request Plugin installed (or curl available on the agent)

Declarative pipeline

pipeline {
  agent any

  environment {
    ALERT24_API_KEY = credentials('alert24-api-key')
  }

  stages {
    stage('Deploy') {
      steps {
        sh './scripts/deploy.sh'
      }
    }
  }

  post {
    success {
      script {
        def payload = [
          summary       : "Deployed ${env.JOB_NAME} @ ${env.GIT_COMMIT[0..7]}",
          change_type   : 'deployment',
          environment   : 'production',
          branch        : env.GIT_BRANCH,
          commit_sha    : env.GIT_COMMIT,
          pipeline_url  : env.BUILD_URL,
          changed_by    : currentBuild.getBuildCauses()[0]?.userId ?: 'jenkins',
          source        : 'jenkins',
          tags          : ['jenkins'],
        ]

        httpRequest(
          url          : 'https://app.alert24.net/api/v1/changes',
          httpMode     : 'POST',
          contentType  : 'APPLICATION_JSON',
          customHeaders: [[name: 'Authorization', value: "Bearer ${ALERT24_API_KEY}"]],
          requestBody  : groovy.json.JsonOutput.toJson(payload),
          validResponseCodes: '200:201'
        )
      }
    }
  }
}

Scripted pipeline (curl)

If you prefer curl over the HTTP Request Plugin:

post {
  success {
    withCredentials([string(credentialsId: 'alert24-api-key', variable: 'ALERT24_API_KEY')]) {
      sh """
        curl -s -X POST https://app.alert24.net/api/v1/changes \\
          -H 'Authorization: Bearer \$ALERT24_API_KEY' \\
          -H 'Content-Type: application/json' \\
          -d '{
            "summary": "Deployed ${env.JOB_NAME} @ ${env.GIT_COMMIT?.take(8)}",
            "change_type": "deployment",
            "environment": "production",
            "branch": "${env.GIT_BRANCH}",
            "commit_sha": "${env.GIT_COMMIT}",
            "pipeline_url": "${env.BUILD_URL}",
            "changed_by": "jenkins",
            "source": "jenkins"
          }'
      """
    }
  }
}

Freestyle project (post-build shell step)

For freestyle projects, add a Post-build Action → Execute shell step (only runs on success):

curl -s -X POST https://app.alert24.net/api/v1/changes \
  -H "Authorization: Bearer $ALERT24_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{
    \"summary\": \"Deployed $JOB_NAME @ ${GIT_COMMIT:0:8}\",
    \"change_type\": \"deployment\",
    \"environment\": \"production\",
    \"branch\": \"$GIT_BRANCH\",
    \"commit_sha\": \"$GIT_COMMIT\",
    \"pipeline_url\": \"$BUILD_URL\",
    \"source\": \"jenkins\"
  }"

Set ALERT24_API_KEY as a Build Environment → Inject passwords variable (requires the EnvInject plugin).

Tips

  • HTTP Request Plugin: Preferred over curl for Jenkins pipelines — handles credentials natively and doesn't expose the API key in build logs.
  • Rollback detection: Check currentBuild.previousSuccessfulBuild — if the deploy is reverting to an older commit, set change_type: 'rollback'.
  • Service ID: Store your Alert24 service ID as a Jenkins global environment variable and reference it in the payload as service_id.