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
| Field | Type | Notes |
|---|---|---|
job | string | Jenkins job name (e.g. backend-tests). |
build_number | int | Jenkins BUILD_NUMBER. |
status | string | One of SUCCESS, FAILURE, UNSTABLE, ABORTED, NOT_BUILT. |
log | string | The full console log. Up to 10 MiB. |
project | string (optional) | Group / repo path for grouping in the dashboard. |
build_url | URL (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
logas a JSON string, not a multipart upload. If your CI doesn’t havejq, embed the log via--data-binary @file.jsonafter building the JSON in a script step. - Logs over 10 MiB are rejected with
413—tail -c 9MB build.logbefore sending in the rare case the log is genuinely larger than that.