CICD-385 · Nx affected project detection
Encyclopedia · Monorepo and large-scale build engineering · All snippets
Previous · CICD-384 · Next · CICD-386
1. Where it fits
- Placement CI run step or authorized lab terminal.
- Prerequisites trusted checkout with the base ref fetched and pinned package manager or build tool.
- Platforms local-linux, github-actions, gitea-actions.
- Parameters
BASE_SHA.
2. Copy the snippet
bash
pnpm exec nx show projects --affected --base="${BASE_SHA:?}" --head=HEAD --json | jq -s '.[0]'3. How it works
The command uses Nx's project graph and a selected Git range to calculate or run affected work. The expression filters or transforms the input JSON. Where jq -e is used, a false or empty result can fail the gate.
4. Verify the result
Use this machine-readable result for a plan job. Confirm dependent packages are listed.
Validation syntax-validated (Bash parse). Status definitions.