Course contentsShow
← Cloud and Infrastructure
Lesson 1776 of 2,98937. JenkinsFree lesson

Build Steps and Post-Build Actions

Configure build steps (shell scripts, tools), post-build actions (notifications, archiving), and understand build lifecycle.

Build Steps and Post-Build Actions

What you'll learn: How Jenkins executes work during a build and what happens after the build completes.

Understanding the Build Lifecycle

Think of a Jenkins job like cooking a meal: build steps are the actual cooking instructions (chop, sauté, bake), while post-build actions are what you do after cooking (garnish, plate, clean up). Jenkins follows this same pattern—work happens during the build, then finishing touches happen afterward, regardless of whether the build succeeded or failed.

Build Steps: The Work Gets Done

Build steps are where Jenkins performs the actual tasks you've defined. In a Freestyle project, you configure these through the Jenkins UI:

  • Execute shell (Linux/Mac) or Execute Windows batch command: Run custom scripts
  • Invoke tool: Call Maven, Gradle, or other build tools
  • Run tests: Execute test suites
  • Copy/move files: Prepare artifacts

Each step runs sequentially. If one fails, Jenkins typically stops and marks the build as failed (unless configured otherwise).

Post-Build Actions: Cleanup and Communication

After all build steps complete (or fail), Jenkins runs post-build actions. These happen after the main work, making them perfect for:

  • Archive artifacts: Save build outputs (JARs, logs, reports) for later retrieval
  • Send notifications: Email teams about build results
  • Trigger other jobs: Start downstream builds
  • Publish test results: Display JUnit reports in Jenkins
  • Clean workspace: Remove temporary files

Post-build actions execute based on build status—some only on success, others always run.

The Complete Flow

A typical build lifecycle: Jenkins checks out code → executes build steps in order → runs post-build actions → marks job complete. This separation ensures critical tasks like notifications happen even when builds break.

Key Takeaway: Build steps perform the actual work of your Jenkins job, while post-build actions handle results, notifications, and cleanup tasks that should happen after the build completes—regardless of success or failure.