Opscraft
Makefile · Lesson 6 of 7 · 3 min read

Make in CI and team workflows

Same commands everywhere

The pipeline should call the same targets developers use:

stage('Test')  { steps { sh 'make lint test' } }
stage('Image') { steps { sh 'make docker-push TAG=$GIT_COMMIT' } }
# GitHub Actions
- run: make lint test
- run: make docker-push TAG=${{ github.sha }}

Benefit: CI logic lives in the repo, is testable locally, and switching CI systems is easy.

Enlarge diagramMakefilelint · test ·docker-pushdeveloper laptopmake lint testJenkinsmake lint testGitHub Actionsmake lint test
Figure 1. Same commands everywhere: the pipeline is a thin wrapper around make targets, so moving CI systems is easy.
Swipe sideways to see all of it, or tap to open it full screen.

"Works locally, fails in CI"

Usual causes: different tool versions (Go, Node, kubectl, terraform), different shells (/bin/sh is dash on Ubuntu agents vs zsh/bash on a Mac), environment variables present locally but not in CI (AWS_PROFILE, PATH entries), BSD vs GNU tools on macOS (sed -i '' vs sed -i), and stale local files make thinks are up to date.

Fixes: pin tools and run targets inside a toolchain container (the TOOLS_IMG pattern: docker run --rm -v $PWD:/w -w /w $(TOOLS_IMG) make test), or use asdf/mise/.tool-versions, set SHELL := bash, and make CI start from a clean checkout.

Windows developers

GNU make isn't native on Windows: use WSL2, run targets in a dev container, or provide equivalent scripts. This is one reason some teams choose cross-platform task runners.

Alternatives

Tool Notes
just (justfile) Make-like syntax without file timestamps or tab pitfalls; command runner only
Task (Taskfile.yml) YAML, cross-platform, supports checksums for up-to-date checks
npm scripts Natural for JS repos
mage Targets written in Go
Bazel / Nx / Pants Large monorepos with remote caching

Make's advantages remain: it's preinstalled almost everywhere, universally understood, and does incremental builds.