Skip to content

fix: git no longer available in container, throws error when using --from-last-tag #4196

Open
@jeohist

Description

@jeohist

Steps to Reproduce

We are using commitlint in our GitLab CI pipelines. With the upgrade to 19.6.0 we noticed unexpected failures, which turns out to be caused by Git no longer being available in the container after #4185.

Config:

commitlint:
  image: commitlint/commitlint:19.5.0
  script:
    npx commitlint --from-last-tag --to "$CI_COMMIT_SHA" --verbose

Current Behavior

Resulting error:

file:///usr/local/lib/node_modules/@commitlint/cli/lib/cli.js:132
        throw err;
        ^
Error: spawn git ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:[28](https://gitlab.rnd.mendix.com/devx/ci-templates/-/jobs/5153376#L28)4:19)
    at onErrorNT (node:internal/child_process:477:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn git',
  path: 'git',
  spawnargs: [
    'describe',
    '--abbrev=40',
    '--always',
    '--first-parent',
    '--long',
    '--tags'
  ]
}
Node.js v18.20.5

Expected Behavior

Commits since last tag should be grabbed and linted.

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

Install Git in the container, not just in the build layer

Context

No response

commitlint --version

19.6.0

git --version

N/A

node --version

v18.20.5

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions