Build History & Status

Every run is recorded in the build history with its number, status, console log, and timing.

Each time a job runs, Jenkins records a build and adds it to the build history panel on the job page.

Build numbers

Builds are numbered sequentially (#1, #2, #3...). The special alias lastBuild and lastSuccessfulBuild always point to the most recent one.

Build status colors

  • Blue / green — success.
  • Yellow — unstable (built, but tests failed).
  • Red — failed.
  • Grey — not built or aborted.

The console output

Click any build, then Console Output, to see the full log of everything that happened. This is your first stop when a build fails.

Example

Example · bash
# You can reach builds by number or alias in the URL:

http://localhost:8080/job/my-app/42/console        # build #42 log
http://localhost:8080/job/my-app/lastBuild/         # newest build
http://localhost:8080/job/my-app/lastSuccessfulBuild/

When to use it

  • A developer opens the console log of a failed build to read the exact error message and failing test name.
  • A team configures log rotation to keep only the last 30 builds, preventing disk space from filling up.
  • A manager checks the build history trend to see if test failures have been increasing over the past week.

More examples

Fetch build log via REST API

Downloads the full console log for a specific build number using the Jenkins REST API.

Example · bash
# Get the console log for build #42
curl -s \
  http://localhost:8080/job/my-app/42/consoleText \
  --user admin:$TOKEN

Configure log rotation in pipeline

Sets log rotation to retain the last 30 builds or builds from the last 90 days, whichever is fewer.

Example · groovy
pipeline {
  agent any
  options {
    buildDiscarder(
      logRotator(numToKeepStr: '30', daysToKeepStr: '90')
    )
  }
  stages {
    stage('Build') { steps { sh 'make' } }
  }
}

List recent builds via REST API

Retrieves the build history for a job as JSON, including build number, result, and timestamp.

Example · bash
curl -s \
  'http://localhost:8080/job/my-app/api/json?tree=builds[number,result,timestamp]' \
  --user admin:$TOKEN \
  | python3 -m json.tool

Discussion

  • Be the first to comment on this lesson.