Reputation: 148
We are using a self-hosted instance of GitLab and we have central pipeline templates that our Dev teams use in their .gitlab-ci file via includes
.
I'm looking to implement commitlint in our shared pipeline templates. I've been able to setup a job that runs on their feature/story branch that validates the most recent commit message whenever a dev pushes up to their remote repository:
echo $CI_COMMIT_MESSAGE | npx commitlint --strict --config $config_file
However, if a dev does multiple commits before pushing(they haven't setup a pre-commit hook) and one of those doesn't match conventional standards, I want my pipeline job to check all commit messages included in their Merge Request.
Using the screenshot attached below, I would expect the middle commit to fail the commitlint job. However, I can't seem to get it to work. I've tried using various Gitlab Pre-defined variables in the --from and --to parameters such as:
--from $CI_MERGE_REQUEST_DIFF_BASE_SHA --to $CI_COMMIT_SHA
but no luck.
The pipeline runs on the source branch when there is an MR pending, but not completed.
Upvotes: 3
Views: 982