It might actually be a bug. I was very confident to have an example using the SHA
variables in our codebase, but it suffers the same problem. A workaround I found for your job:
lint commit messages:
stage: test
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
script:
- git fetch
- poetry run gitlint --commits "origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}..origin/${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}"
I switched to the rules
syntax, GitLab recommends doing so:
The rules syntax is an improved, more powerful solution for defining when jobs should run or not. Consider using rules instead of only/except to get the most out of your pipelines.
Results in:
$ poetry install
Installing dependencies from lock file
No dependencies to install or update
$ git fetch
From https://gitlab.com/KiwiKilian/pacman-package-file
* [new branch] lint -> origin/lint
* [new branch] master -> origin/master
$ poetry run gitlint --commits "origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}..origin/${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}"
Commit 7c9f4e7c1a:
1: CT1 Title does not start with one of fix, feat, chore, docs, style, refactor, perf, test, revert, ci, build: "Ignore IDEA configuration"
1: CT1 Title does not follow ConventionalCommits.org format 'type(optional-scope): description': "Ignore IDEA configuration"
Cleaning up file based variables
00:00
ERROR: Job failed: exit code 1