Back to lessons

Hosting Operations

Scan Every CI Log for Error Lines

Multiple CI logs may contain errors, warnings, stack traces, and test failures, but opening each file manually is slow.

Command

grep -RInE 'error|failed|failure|exception|traceback' artifacts logs | head -50

What changed

Nothing changes. grep prints matching file names, line numbers, and excerpts.

Danger

safe

When to use it

Use for the first pass over CI logs when the failing stage is unclear.

When not to use it

Do not treat every warning-like match as fatal; confirm with the surrounding log context.

Undo or recovery

No undo needed because this command is read-only.

Expected output

Matching error-like lines with file paths and line numbers.

demo script

Disposable terminal steps

  1. cd /lab/ci-artifacts && grep -RInE 'error|failed|failure|exception|traceback' artifacts logs | head -50
  2. cd /lab/ci-artifacts && grep -RInE 'error|failed|failure|exception|traceback' artifacts logs | cut -d: -f1 | sort -u
  3. cd /lab/ci-artifacts && sed -n '1,120p' artifacts/test/pytest.log

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ cd /lab/ci-artifacts && grep -RInE 'error|failed|failure|exception|traceback' artifacts logs | head -50
artifacts/build/webpack.log:1:webpack 5.91.0 compiled with 1 error
artifacts/build/app-build.log:5:Build failed with exit code 1
artifacts/test/pytest.log:6:tests/test_billing.py::test_invoice passed on retry after failed attempt 1
artifacts/test/pytest.log:7:1 failed, 2 passed, 1 rerun
artifacts/test/junit.xml:1:
artifacts/test/junit.xml:4:    AssertionError
logs/deploy.log:4:Deploy failed: missing artifacts/dist/robots.txt
::exit-code::0
$ cd /lab/ci-artifacts && grep -RInE 'error|failed|failure|exception|traceback' artifacts logs | cut -d: -f1 | sort -u
artifacts/build/app-build.log
artifacts/build/webpack.log
artifacts/test/junit.xml
artifacts/test/pytest.log
logs/deploy.log
::exit-code::0
$ cd /lab/ci-artifacts && sed -n '1,120p' artifacts/test/pytest.log
============================= test session starts =============================
tests/test_api.py::test_health PASSED
tests/test_api.py::test_create_user FAILED
Traceback (most recent call last):
  AssertionError: expected 201 got 500
tests/test_billing.py::test_invoice passed on retry after failed attempt 1
1 failed, 2 passed, 1 rerun
::exit-code::0

YouTube Short

Search all CI logs at once.

Do not open ten logs by hand. Search every artifact for error, failed, exception, and traceback first.

LinkedIn hook

One grep pass can turn a log pile into a failure list.

Question: What words do you search for first in a failed CI artifact bundle?

experiments

A/B tests to run

Metric: linkedin_save_rate

A: One grep pass can turn a log pile into a failure list.

B: Search every CI artifact for failure words.