"changes" jobs should not run if pattern doesn't match
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
When it comes to CI jobs using the changes: check, GitLab's documentation states that "Without a target branch, it is not possible to know what the common ancestor is, thus we always create a job in that case."
This makes total sense; however, if no files match the pattern at all, there is really no reason to run these jobs. Take this for example:
.lint:js: &lint_js
script:
- >
if [ `find . -name "*.js" | wc -l` -gt 0 ]; then
eslint -c /etc/eslint.json -f junit -o eslint-results.xml .;
fi
allow_failure: true
only:
changes:
- "*.js"
- "**/*.js"
artifacts:
reports:
junit: eslint-results.xml
When I create a new merge request, this job should not run at all if there are no JavaScript files in the repository.
Edited by 🤖 GitLab Bot 🤖