gitlab-ci "rules" should support extended globbing or some negation of changes/exists
Problem to solve
I would like to run a gitlab ci job only if at least one file was changed and changed files were not all html files.
Assuming a repository made of many types of files. Assume you want to run a compile job only if the commit does not contain only documentation changes (such as *html files only).
The CI keyword allows pattern matching, but does not allow any sort of negation pattern matching.
For that reason, the only way to run the job if any file was changed but not only html files were changed is to list in the "rules: changes:" the entirety of all file extensions, and all files with no extensions.
If changes/exists supported extended globbing, or some sort of negation, this unwieldy workaround would not be necessary.
Support extended globbing, akin what bash can do:
only: changes: - "**/!(*.html)"
will run the job if:
- foobar.txt was changed,
- foobar.txt + foobar.html were changed,
but will not run the job if
- foobar.html was changed
The following would be equivalent to bash extended globbing:
mkdir code doc touch code/foobar.cpp doc/index.html shopt -u globstar shopt -s extstar ls **/!(*.html)