TExcelTAD
Home › CI/CD Pipelines & Pipeline Security › Field Notes: Pipelines People Trust

Field Notes: Pipelines People Trust

A pipeline is only useful if people believe its verdict. When it is slow, flaky or mysterious, developers learn to re-run it until it's green, to bypass it "just this once", and eventually to stop reading it. These notes are the habits that keep pipelines trusted, collected from running them.

Treat a flaky pipeline as an outage

A pipeline that fails one run in ten for no reason costs more than the minutes: it teaches the team that red means nothing. Track re-run rate and failure causes (test, infrastructure, dependency download, timeout) per week. Quarantine flaky tests the day they're found (Tests in CI), retry infrastructure steps (downloads, registry pushes) with backoff, and never retry test commands blindly.

Pin everything the pipeline runs

The pipeline that passed yesterday should pass today on the same commit. That only holds if nothing outside the commit changed:

  • runner images (ubuntu-24.04, not ubuntu-latest), container images by version or digest;
  • actions and included templates by SHA or tag (Hardening Workflows);
  • tools downloaded in jobs (Trivy, kubectl, Helm) at fixed versions with checksums;
  • language toolchains through version files (.nvmrc, .python-version, go.mod's toolchain), dependencies through lockfiles.

Then update them on purpose, through bot pull requests that run the same pipeline. "It broke because GitHub updated the image" should never be a sentence in a postmortem.

Make every job runnable locally

If debugging a CI failure requires pushing commits called "try again", the pipeline logic lives in the wrong place. Keep commands in make/scripts (Pipeline as Code), keep secrets out of the build steps (only deploy steps need them), and use gitlab-ci-local or act for the glue. A developer should reproduce a red build with one command.

Timeouts on everything

The default job timeout is hours (360 minutes on GitHub, 60 on GitLab by default per project). A hung integration test then holds a runner for the whole period and blocks deployments behind it in the concurrency queue. Set timeout-minutes/timeout per job at about three times the normal duration, and timeouts inside scripts for network calls (curl --max-time, kubectl rollout status --timeout).

A pipeline linter for your own repositories

Many of these smells can be found mechanically. The session runs a small checker over two workflow files; it's a few lines of grep and awk that you can grow into a scheduled job across all repositories (actionlint and zizmor do much more, see the Toolkit):

bash · try it yourself
mkdir -p .github/workflows
cat > .github/workflows/ci.yml <<'YML'
name: ci
on: [push]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: some-org/setup-tool@main
      - run: curl -s https://example.com/install.sh | bash
      - run: npm test
YML
cat > .github/workflows/deploy.yml <<'YML'
name: deploy
on:
  push:
    branches: [main]
permissions:
  contents: read
jobs:
  deploy:
    runs-on: ubuntu-24.04
    timeout-minutes: 20
    environment: production
    steps:
      - uses: actions/checkout@v7
      - run: ./ci/deploy.sh
YML
cat > pipeline-doctor.sh <<'SH'
#!/usr/bin/env bash
# pipeline-doctor.sh FILE...: report common workflow smells; exit 1 if any
status=0
warn() { echo "$1: $2"; status=1; }
for f in "$@"; do
  grep -q '^permissions:' "$f"            || warn "$f" "no top-level permissions (token defaults may be write)"
  grep -q 'timeout-minutes:' "$f"         || warn "$f" "no timeout-minutes (default is 360)"
  grep -n 'runs-on: .*-latest' "$f"       | while IFS=: read -r n _; do echo "$f:$n: unpinned runner image"; done
  grep -nE 'uses: [^ ]+@(main|master)\b' "$f" | while IFS=: read -r n _; do echo "$f:$n: action pinned to a branch"; done
  grep -nE 'curl[^|]*\|[[:space:]]*(ba)?sh' "$f" | while IFS=: read -r n _; do echo "$f:$n: pipes a download into a shell"; done
  grep -qE 'runs-on: .*-latest|@(main|master)\b|curl[^|]*\|[[:space:]]*(ba)?sh' "$f" && status=1
done
[ $status -eq 0 ] && echo "no smells found"
exit $status
SH
chmod +x pipeline-doctor.sh
./pipeline-doctor.sh .github/workflows/*.yml
echo "exit $?"
.github/workflows/ci.yml: no top-level permissions (token defaults may be write)
.github/workflows/ci.yml: no timeout-minutes (default is 360)
.github/workflows/ci.yml:5: unpinned runner image
.github/workflows/ci.yml:8: action pinned to a branch
.github/workflows/ci.yml:9: pipes a download into a shell
exit 1

deploy.yml is clean; ci.yml collects five findings. Run a checker like this on a schedule across the organisation and post the results where the owning teams see them.

Notifications people read

A channel that receives every green build is muted within a week. Notify on state changes (main went red, main recovered), to the people who can act (the author of the breaking commit, the owning team), with the failing step and a link. Deployment notifications are different: post every production deployment, with version, author and link, because that is the first place people look when something breaks.

Deploy small, deploy often, deploy when people are around

"Never deploy on Friday" is a symptom: deployments are risky because they are big and rare. The cure is the opposite: small changes, automatic rollback, canaries (Canary Releases). Until you're there, a reasonable rule is to deploy when the people who can fix things are awake and not about to leave, and to use deploy freezes (a protected environment rule, a calendar check in the pipeline) for genuinely high-risk periods such as a sales peak.

The pipeline has an owner

Shared pipeline code (reusable workflows, GitLab components, Jenkins shared libraries) needs an owning team, a changelog, versioned releases and a way for service teams to ask for changes. Unowned pipeline code rots like any unowned code, except it rots with production credentials attached.

Watch the cost

CI minutes, runner fleets, artifact storage and egress add up. The usual savings, in order of payoff: cancel superseded runs on PR branches (concurrency with cancel-in-progress, GitLab interruptible), path filters for monorepos, caching dependencies, shorter artifact retention, and right-sized runners (a 2-core runner waiting on the network is wasted money on a 16-core one).

Test yourself

What is the healthiest response to a test that fails randomly one run in twenty?

  1. Add automatic retries to the test command
  2. Quarantine it in a non-blocking job, track it, and fix it
  3. Delete the test
  4. Ignore it

Why pin runner images and tool versions in the pipeline?

  1. It's faster
  2. So the same commit gives the same result; updates then arrive as reviewed, tested changes
  3. GitHub requires it
  4. To save storage

Which notifications should go to a team channel on every occurrence?

  1. Every green build
  2. Production deployments (version, author, link)
  3. Every lint warning
  4. Cache misses