Home / Companies / Semaphore / Blog / Post Details
Content Deep Dive

Why Do Builds Pass Locally but Fail in CI?

Blog post from Semaphore

Post Details
Company
Date Published
Author
Semaphore Team
Word Count
1,105
Language
English
Hacker News Points
-
Summary

"Works on my machine" is a frequent issue in test automation and CI/CD where builds succeed locally but fail in continuous integration, often due to differences between local and CI environments. Local environments can accumulate cached dependencies and other states over time, whereas CI environments are designed to be clean and reproducible with explicitly declared dependencies and no hidden state. A common problem is undeclared dependencies that exist locally but not in CI, leading to failures that CI is meant to expose. Explicitly declaring dependencies and committing lock files, which ensure consistent dependency versions across environments, are crucial for reliable CI/CD pipelines. Other factors contributing to discrepancies include missing environment variables, OS and file system differences, hidden test states, and flaky tests that CI environments can reveal due to their parallel execution and resource constraints. By aligning local environments with CI and treating CI as the source of truth, teams can mitigate "works on my machine" problems and build stable, predictable automation pipelines.