<!--
title: maintain build environment parity
domain: security
topic: CI/CD
language: Other
source: snyk/cli
updated: 2024-04-18
url: https://awesomereviewers.com/reviewers/cli-maintain-build-environment-parity/
-->

Ensure that local development and CI/CD environments use identical build commands and dependency management strategies to prevent deployment issues and environment drift. When introducing local-specific build targets, consider whether the same approach should be adopted in CI pipelines to maintain consistency.

Avoid creating separate build paths that could diverge over time. Instead of having different commands like `build` vs `build-local`, standardize on a single approach that works across all environments.

For dependency management, be consistent about when to use clean installs vs incremental installs:

```makefile
# Instead of different targets:
build-local: pre-build
	source .venv/bin/activate; make build-full

# Prefer unified approach:
build: pre-build
	@if [ -f .venv/bin/activate ]; then source .venv/bin/activate; fi
	make build-full
```

When optimizing for performance (like using `npm i` instead of `npm ci`), ensure the optimization logic is consistent between local and CI environments, or clearly document why they differ.
