Maintain Azure DevOps pipelines and GitHub Actions
Learning objectives
- Diagnose pipeline health using comparable run, duration and test populations.
- Evaluate optimizations without hiding failures or weakening required evidence.
- Separate retention policies for runs, package versions and disposable caches.
Define the health population
Start a maintenance review with a real branch, observation window and eligible run set. Failure rate, queue delay, execution duration and individual task duration answer different questions. The adopted Azure duration analytics concern successful runs; comparing them with an all-run sample changes the measure. A queue bottleneck is not automatically slow application code.
Test analytics requires published results. One test failing in ten runs creates repeated failure instances, not ten distinct failing tests. Flakiness means nondeterminism under apparently equivalent conditions; a failed test is not necessarily flaky. Inspect history and verify a proposed correction rather than hiding its count.
Azure DevOps supports system and custom flaky detection in the applicable VSTest/rerun contexts. Switching detection systems can erase history, and marking behavior affects future results. Suppressing flaky failures changes a summary's displayed population; it does not remove the defect. A green report obtained through suppression is not independent reliability evidence.
An actionable investigation records the run/branch/window, compares compatible cohorts, opens the relevant task and test evidence, and assigns a specific follow-up. A queued run, an unpublished result and a failed assertion are distinct observations. No tenant chart is claimed to have been inspected for this lesson.
Optimize the observed bottleneck
Adding eligible workers cannot exceed Azure Pipelines parallel-job entitlement. More jobs can increase contention or idle expense. Optimize the critical path and unnecessary regeneration while preserving required checks. An improvement achieved by skipping tests or suppressing failures changes the quality contract.
For an illustrative comparable dependency step, regeneration takes 120 seconds. A cache restores in 20 seconds and saves in 10 seconds, with these phases treated as sequential and nonoverlapping. Its elapsed cost is 30 seconds and its elapsed saving is 120 − 30 = 90 seconds. A 150-second transfer would instead be slower than regeneration. These are teaching inputs, not product benchmarks or measured hands-on labor savings.
Encode relevant OS, runtime and dependency-lock identity in cache keys. Content under a key is immutable; a miss should cause normal regeneration. Install documented archive tooling on self-hosted agents and verify paths/permissions. A dependency cache is reusable acceleration, not the exact approved release artifact.
GitHub cache access follows branch/merge-ref scope. PR-created entries can be restricted to that merge ref. The adopted current low-trust defaults make relevant contexts read-only, but explicit cache-mode exceptions exist; inspect the actual action/caller contract rather than asserting an unconditional prohibition. Cache content is unsigned. Store no secrets and do not treat untrusted cached bytes as approved release provenance.
Eviction, storage pressure and repeated misses can cause thrashing. Current inactivity/size limits can change and excess storage may be billed; select an explicit caller cap where supported. A useful optimization compares end-to-end cost and reliability, including misses, rather than timing only a hit.
Bound retries to understood transient failures. A partially applied write is not made idempotent by retry configuration. Task timeouts remain inside job timeouts, and continueOnError changes downstream outcome interpretation. Preserve those semantics when tuning duration and recovery.
Retain runs according to their actual protection
In the adopted Azure Pipelines model, configure retention through Project settings → Pipelines → Settings, with repository-specific recent-run treatment rather than assuming a universal per-pipeline control. A run becomes eligible for deletion only when all four conditions hold:
- Its retention age has been exceeded.
- It is outside the recent runs retained by policy.
- It is not retained indefinitely.
- It is not retained by a release.
For Azure Repos, recent-run treatment considers the default branch, each protected branch and the pipeline overall. Other Git repositories and TFVC use the pipeline overall. Processing occurs daily at a variable time, not at an exact user-selected instant. Release and test-retention settings are separate. Inspect the selected run's current protection before predicting its deletion.
For an illustrative run older than the configured age, a release-retained flag still prevents eligibility. A run meeting all four predicates is eligible for periodic processing, not guaranteed to disappear immediately. A missing or unknown protection state needs inspection rather than an assumed unprotected result.
Deleting a run removes associated logs, artifacts, test results and metadata. Preserve required release provenance and recovery evidence first. This deletion does not manage independent registries. GitHub artifact retention is bounded by repository/organization policy; a requested longer interval cannot override that limit. Cross-run recovery also requires the original run, authorized access and actual integrity checks. A digest mismatch warning is not an enforced hard rejection.
Manage dependency versions separately
For Azure Artifacts, open Artifacts → Feed settings → Feed details → Enable package retention. Set Maximum number of versions per package and Days to keep recently downloaded packages, then Save. Automatic removal needs both the maximum-version criterion and no download within the configured recent-download interval. A version promoted to a view is exempt.
The two conditions matter together. In an illustrative feed over its configured version maximum, a recently downloaded version does not meet the no-recent-download condition. An eligible unpromoted version can be soft-deleted by daily processing. Deleted versions remain in the recycle bin for 30 days and count toward storage until permanently removed.
Deprecation, unlisting and yanking communicate or constrain consumption differently from deleting bytes. A recycle window does not allow changed content to be republished under the same immutable version. Review downstream lockfiles and consumers before removing a dependency version. Do not apply feed predicates to pipeline runs or caches.
Keep accelerators out of the recovery contract
Caches can disappear through last-access eviction, storage pressure or policy. They are disposable and regenerable. Keep deployment artifacts, source/run identities and required evidence under intentional retention. The design should state which bytes can be regenerated, which must survive, who may delete them and how recovery is checked.
Before cleanup, inspect actual protected objects and their dependencies. Preserve the agreed recovery/audit period rather than deleting solely because a run is old. These are retention design rules and expected cases; no cleanup action was executed for the lesson.
Summary
Use comparable health populations to diagnose the real bottleneck, then optimize elapsed cost without dropping verification. Keep flaky-test presentation separate from reliability. Apply run, package and cache rules to their own objects, retaining the exact release bytes and provenance needed for recovery before removing routine data.
