Artifact Management in Pipelines
What you'll learn: How to build once and reuse the same immutable artifact across all pipeline stages for reliability and consistency.
The Core Idea
When your code passes through a deployment pipeline—from commit to production—you want absolute certainty that what you tested is exactly what you're deploying. Artifact management means you build your software once at the beginning of the pipeline, then promote that identical, unchangeable (immutable) artifact through every subsequent stage: testing, staging, production.
Think of it like baking a cake once, then moving that same cake through quality inspection, presentation review, and finally the customer's table. You don't bake a new cake at each step—you'd risk inconsistencies. The same principle applies to software.
Why Build Once?
If you rebuild at each pipeline stage, you introduce risk:
- Different timestamps or environment variables might create subtle variations
- Dependency versions could change between builds
- Compilation optimizations might differ
- You waste time rebuilding identical code
By building once and storing the artifact (a compiled binary, Docker image, JAR file, etc.), you guarantee that staging tests validate the exact same bits heading to production.
How It Works
- Build stage creates the artifact (e.g.,
app-v1.2.3.jar) - Store it in an artifact repository with a unique identifier
- Subsequent stages retrieve and deploy that same artifact
- Configuration changes between environments, but the artifact stays identical
The artifact becomes your "golden copy"—tested, verified, and trusted.
Key Takeaway: Build your artifact once at the pipeline's start and promote that immutable package through all stages—never rebuild—to ensure what you test is exactly what you deploy.