Files
devops-lib-gcp/docs/review-learnings.md
T
2026-08-26 02:02:24 +05:30

1.9 KiB

buildNode.groovy: pnpm must be globally installed before invoking pnpm commands

Takeaway: When auto-selecting the install command in buildNode.groovy based on lockfile presence, pnpm must be installed globally first (npm install -g pnpm@<version>) — emitting pnpm install --frozen-lockfile alone will fail in environments where pnpm is not on the PATH.

Pattern: Any time buildNode.groovy detects a pnpm-lock.yaml and constructs an npm_install_arg that invokes pnpm, the command string must prefix with a global install step. The version should be pinned to avoid silent drift.

Rationale: Jenkins agents running Node builds do not have pnpm pre-installed. The auto-selection logic that branches on fileExists("${repo_name}/pnpm-lock.yaml") is responsible for producing a self-contained, executable command string — if pnpm is absent from the agent PATH the build fails with a command-not-found error. Reviewers also flagged that lock-file cleanup helpers should cover pnpm-lock.yaml alongside package-lock.json.

Concrete example (from PR #727, src/com/meesho/stages/buildNode.groovy:L193):

// Before (incomplete — pnpm not guaranteed on PATH)
if (fileExists("${repo_name}/pnpm-lock.yaml")) {
    npm_install_arg = 'pnpm install --frozen-lockfile'
}

// After (reviewer-suggested correction)
if (fileExists("${repo_name}/pnpm-lock.yaml")) {
    npm_install_arg = 'npm install -g pnpm@10.33.0 && pnpm install --frozen-lockfile'
}

Examples from PRs:

  • PR #727: Auto-selection logic added for pnpm/npm-ci/npm-install; reviewer caught that pnpm must be globally installed first.
  • PR #728: Reviewer noted cleanup helpers should also handle pnpm-lock.yaml.