Skip to content
Exlogare

Jenkins ingest

Send Jenkins console logs to Exlogare from a declarative pipeline, scripted pipeline, or a freestyle post-build script.

Exlogare’s POST /api/ingest/jenkins endpoint accepts the full console log of a failed Jenkins build and returns an RCA. Below are copy-paste integrations for every Jenkins pipeline style.

Required fields

FieldTypeNotes
jobstringJenkins job name (e.g. backend-tests).
build_numberintJenkins BUILD_NUMBER.
statusstringOne of SUCCESS, FAILURE, UNSTABLE, ABORTED, NOT_BUILT.
logstringThe full console log. Up to 10 MiB.
projectstring (optional)Group / repo path for grouping in the dashboard.
build_urlURL (optional)Deep link back to the Jenkins build page.

Declarative pipeline

pipeline {
  agent any
  stages {
    stage('Test') {
      steps { sh 'make test 2>&1 | tee build.log; exit ${PIPESTATUS[0]}' }
    }
  }
  post {
    failure {
      sh '''
        curl -fsS -X POST https://api.exlogare.net/api/ingest/jenkins \
          -H "Authorization: Bearer ${EXLOGARE_TOKEN}" \
          -H "Content-Type: application/json" \
          --data-binary @- <<JSON
{
  "job": "${JOB_NAME}",
  "build_number": ${BUILD_NUMBER},
  "status": "FAILURE",
  "project": "${JOB_BASE_NAME}",
  "build_url": "${BUILD_URL}",
  "log": $(jq -Rs . build.log)
}
JSON
      '''
    }
  }
}

Bind EXLOGARE_TOKEN via Jenkins Credentials → secret text and inject it into the pipeline with the withCredentials step.

Scripted pipeline

node {
  try {
    sh 'make test 2>&1 | tee build.log; exit ${PIPESTATUS[0]}'
  } catch (err) {
    sh """
      curl -fsS -X POST https://api.exlogare.net/api/ingest/jenkins \
        -H "Authorization: Bearer \${EXLOGARE_TOKEN}" \
        -H "Content-Type: application/json" \
        -d "\$(jq -n \\
          --arg job '\${env.JOB_NAME}' \\
          --arg url '\${env.BUILD_URL}' \\
          --arg log "\$(cat build.log)" \\
          '{job:\$job, build_number:\${env.BUILD_NUMBER}, status:"FAILURE", build_url:\$url, log:\$log}')"
    """
    throw err
  }
}

Freestyle build (post-build “Execute shell”)

For freestyle jobs, use the Post-build Actions → Execute shell on build condition with “Run only when build succeeds or fails” set to “Failure”:

#!/usr/bin/env bash
set -euo pipefail
LOG_PATH="$WORKSPACE/build.log"
curl -fsS -X POST https://api.exlogare.net/api/ingest/jenkins \
  -H "Authorization: Bearer $EXLOGARE_TOKEN" \
  -H "Content-Type: application/json" \
  -d "$(jq -n \
    --arg job  "$JOB_NAME" \
    --arg url  "$BUILD_URL" \
    --arg log  "$(cat "$LOG_PATH")" \
    '{job:$job, build_number:'$BUILD_NUMBER', status:"FAILURE", build_url:$url, log:$log}')"

Common pitfalls

  • jq -Rs . is the safest way to escape an arbitrary log into a JSON string — handles newlines, quotes, and backslashes correctly.
  • The endpoint expects log as a JSON string, not a multipart upload. If your CI doesn’t have jq, embed the log via --data-binary @file.json after building the JSON in a script step.
  • Logs over 10 MiB are rejected with 413tail -c 9MB build.log before sending in the rare case the log is genuinely larger than that.