Stop 06 · CI/CD PipelinesTopics · 5/10

Build Automation

Part of the DevOps Roadmap

In short

'It builds on my machine' isn't a release process. Build automation means one command, run the same way by every laptop and every pipeline, turns source code into something you can ship.

Automatically compiling, packaging, and preparing code for deployment as part of a pipeline — removing manual, error-prone build steps from the release process entirely.

The mascot feeds dough into a roti-making machine while identical round rotis roll out the other end.

Think of it like this

The roti machine at the hostel mess

Hand-rolled rotis come out thick, thin, round or oval depending on who's rolling. The mess's roti machine takes the same dough and gives the same roti every single time, hundreds per hour. Build automation is that machine for your code.

Watch it happen

make image on a CI runner

CI runner
Cache
Registry

restore node_modules

1/5The runner restores dependencies cached from the last build, keyed on the lockfile.

The big ideas

What you need to know

One command to build

make build or npm run build should be all anyone needs. The pipeline calls the same command.

Lock your dependencies

Commit lockfiles and use npm ci or pip install -r with pinned versions, so builds don't change overnight.

Cache wisely

Cache downloaded dependencies keyed on the lockfile's hash. Invalidate when it changes.

Tag builds traceably

Tag every output with the commit SHA or version, so you can always tell which code is running.

See it in code

Walk through the code

makefile
1VERSION := $(shell git rev-parse --short HEAD)2 3.PHONY: test build image4test:5	npm ci6	npm test7 8build: test9	npm run build10 11image: build12	docker build -t shop-api:$(VERSION) .

1/4Use the short commit SHA as the version, so every image traces back to its code.

Makefile recipe lines must start with a real tab, not spaces. make image now runs test, then build, then image, in order.

Save yourself the pain

Common mistakes

Oops

Having a 20-step build written only in the CI file, impossible to run locally.

Do this instead

Put build steps in a Makefile or package.json scripts. CI and developers then run the exact same thing.

Oops

Using npm install in CI, which can quietly pick newer dependency versions.

Do this instead

Use npm ci, which installs exactly what package-lock.json says and fails if it's out of sync.

Your mission

One-command build

~25 min

Quick check

Why tag a build output with the Git commit SHA?

Go deeper

  1. 1Automate a build step (e.g. installing dependencies, compiling code) inside a CI pipeline.
  2. 2Learn why build reproducibility (locking dependency versions) matters for reliable pipelines.
  3. 3Practice caching dependencies in a pipeline to speed up repeated builds.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge