Master Jenkins From Beginner to Enterprise

Clear, interactive, and structured Jenkins lessons designed to take you from beginner to enterprise level.

Artifacts and Build Outputs

Learn the concepts, preservation step methods, wildcards matching syntax, and post-build workflows required to securely capture and archive your pipeline's compiled output binaries.

What are Artifacts and Build Outputs?

In continuous integration, a successful compilation stage produces physical assets like `.jar`, `.war`, `.zip` files, or test diagnostic reports. These compiled deliverables are known as Artifacts. Because Jenkins agent node workspaces are transient and often wiped between jobs to save room, key outputs must be safely exported to the controller node for permanent preservation.

Simple Definition: Artifacts are the final, compiled files or test reports generated by your automation pipeline that Jenkins extracts from temporary worker nodes and archives on the master server so users can download them later.

Core Archival Rules

Managing build outputs effectively relies on three specific execution and structural patterns:

  • The `archiveArtifacts` Step: The dedicated post-build instruction directive used to pull targeted file formats out of the isolated workspace directory structure before the agent node spins down.
  • Ant-Style Wildcard Matching (`**/*`): The file matching syntax structure used to filter out noise and isolate target file paths (e.g., targeting `target/*.jar` to capture compiled Java binaries while ignoring intermediate `.class` files).
  • Long-Term Retention: Saved files are bound directly to the historic metadata profile page of that specific individual build number, making them accessible via the web interface dashboard or API calls.

Key Concepts

Workspace vs. Persistent Storage

Understanding that workspace files are volatile and easily lost during cleanup processes, whereas stored artifacts are copied to the controller's file system, guaranteeing long-term tracking capability.

Downstream Packaging Deliveries

Learning to pass successfully compiled build output artifacts directly into subsequent testing or deployment pipelines across separate server nodes using the Copy Artifact plugin.

Practical Jenkins Example

The following declarative blueprint demonstrates how to compile a mock software binary package and configure an automated asset fallback archive operation inside the `post` completion block:

pipeline {
    agent any











    stages {
        stage('Compile and Package Application') {
            steps {
                echo 'Initializing application build script targets...'
                // Creating a mock directory structure and population file
                sh 'mkdir -p dist/'
                sh 'echo "Build Executable Payload v1.0.0" > dist/app-payload.jar'
                sh 'echo "System Metrics Log" > dist/test-report.html'
                sh 'ls -la dist/'
            }
        }
    }

    // Archiving build deliverables securely once execution stages terminate
    post {
        success {
            echo 'Active build stages passed successfully. Migrating output files to controller storage...'
            // Archiving all HTML files and JAR packages inside the dist folder
            archiveArtifacts artifacts: 'dist/*.jar, dist/*.html', fingerprint: true, onlyIfSuccessful: true
        }
        failure {
            echo 'Pipeline abnormalities detected. Bypassing asset packaging workflows.'
        }
    }
}

Practice Exercise: Package and Archive a Build Deliverable

Step-by-Step Task Sequence:
  1. Open the pipeline script editor screen for an existing test job tracking setup or instantiate a new Pipeline item dashboard.
  2. Copy-paste the complete practical declarative pipeline example containing the `archiveArtifacts` block shown above into your code terminal window and click Save.
  3. Trigger an immediate manual pipeline execution pass by selecting the **Build Now** action link located on the left-hand option hierarchy menu.
  4. Open the **Console Output** view panel for the active run counter to verify that the file migration step completed without throwing access exceptions.
  5. Return to the main summary overview landing screen for this specific build number run—you will observe a fresh, interactive **Build Artifacts** section where your archived files can be directly inspected and downloaded.

Summary

You have completed the Artifacts and Build Outputs lesson. Continue through the syllabus to learn how to sequence multiple dependent automated workflows using Upstream and Downstream Jobs.