Maintaining pipelines
Pipeline health, flaky tests, optimising for cost, time, performance and reliability, concurrency, and retention.
In this lesson you'll learn
- Monitoring failure rate, duration and flaky tests
- Optimising pipelines for cost, time, performance and reliability
- Tuning concurrency
- Retention for runs, artifacts and packages
1. Pipeline health
Azure Pipelines analytics show pass rate, failure trends, duration by task and test failures over time. Watch for: a falling pass rate, steps that keep getting slower, and flaky tests. Azure Pipelines can detect flaky tests and exclude them from failing the build while they're fixed. GitHub shows workflow run history and usage metrics.
2. Optimising
- Time: cache dependencies (Cache@2,
actions/cache), run jobs in parallel, use path filters, shallow clone, build incrementally. - Cost: Linux agents where possible, fewer wasted runs (path filters, cancelling superseded runs), self-hosted or managed pools for heavy use, right-sized parallel jobs.
- Performance: bigger agents for heavy builds, warm caches on self-hosted agents.
- Reliability: pinned tool and action versions, retries for known transient steps, fixing flaky tests rather than re-running.
3. Concurrency
More parallel jobs shorten queues but cost money. Limit concurrent runs per pipeline where order matters (a deployment shouldn't run twice at once): exclusive lock checks on environments in Azure Pipelines, and concurrency: groups with cancel-in-progress in GitHub Actions.
4. Retention
Keep what you need for audits and rollbacks, and delete the rest. Azure Pipelines has project-level retention policies for runs, artifacts and attachments, plus retention leases that keep specific runs (such as production releases). Azure Artifacts feeds can keep only the latest N versions of each package. GitHub sets retention for artifacts and logs (default 90 days, configurable).
Example
SS Kaiser's build took 14 minutes. Caching npm packages saved 4, splitting tests across 3 parallel jobs saved 5, and a path filter stopped docs changes building at all. Production runs are kept for a year with retention leases; everything else for 30 days.
Exam traps to remember
- Cache@2 and actions/cache save dependency downloads between runs.
- Retention leases keep specific runs beyond the normal policy.
- Exclusive lock stops two deployments to one environment at once.
Test yourself: 3 check questions and exam-style practice questions on this topic are in the AZ-400 DevOps Engineer app.
Practise in the app