Back to lessons

Hosting Operations

Find the Largest CI Artifacts

CI upload, cache, or packaging steps are slow or failing, and oversized artifacts may be the cause.

Command

find artifacts -type f -printf '%s %p\n' | sort -nr | head -10

What changed

Nothing changes. The shell prints the largest artifact files.

Danger

safe

When to use it

Use when artifact upload, cache restore, package creation, or disk usage looks suspicious.

When not to use it

Do not delete artifacts from this output alone; confirm which files are required.

Undo or recovery

No undo needed because this command is read-only.

Expected output

The ten largest artifact files with byte sizes and paths.

demo script

Disposable terminal steps

  1. cd /lab/ci-artifacts && du -sh artifacts/*
  2. cd /lab/ci-artifacts && find artifacts -type f -printf '%s %p\n' | sort -nr | head -10
  3. cd /lab/ci-artifacts && find artifacts -type f -printf '%s %p\n' | sort -nr | awk 'NR<=5 {printf "%.1f KB %s\n", $1/1024, $2}'

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ cd /lab/ci-artifacts && du -sh artifacts/*
12K	artifacts/build
12K	artifacts/coverage
20K	artifacts/dist
12K	artifacts/test
::exit-code::0
$ cd /lab/ci-artifacts && find artifacts -type f -printf '%s %p\n' | sort -nr | head -10
831488 artifacts/dist/assets/vendor.js
250880 artifacts/dist/assets/main.js
450 artifacts/test/junit.xml
338 artifacts/test/pytest.log
139 artifacts/build/webpack.log
137 artifacts/build/app-build.log
131 artifacts/coverage/coverage-summary.txt
87 artifacts/coverage/coverage-summary.json
77 artifacts/dist/index.html
::exit-code::0
$ cd /lab/ci-artifacts && find artifacts -type f -printf '%s %p\n' | sort -nr | awk 'NR<=5 {printf "%.1f KB %s\n", $1/1024, $2}'
812.0 KB artifacts/dist/assets/vendor.js
245.0 KB artifacts/dist/assets/main.js
0.4 KB artifacts/test/junit.xml
0.3 KB artifacts/test/pytest.log
0.1 KB artifacts/build/webpack.log
::exit-code::0

YouTube Short

Find bloated artifacts fast.

If CI is slow around upload or packaging, list artifacts by size. The biggest file often explains the delay.

LinkedIn hook

A bloated artifact can explain a slow or failed pipeline.

Question: Have oversized artifacts ever slowed down your CI pipeline?

experiments

A/B tests to run

Metric: short_click_through_rate

A: A bloated artifact can explain a slow or failed pipeline.

B: Sort CI artifacts by size.