Reputation: 241
I need to skip a GitLab CI job in my pipeline, if the only changes part of my commit/merge request
are related to *.md, eslintrc.json or jsconfig.json
files.
Examples:
I have tried to accomplish this, but I have not found except:changes
nor rules:when:never
useful so far. How can I do it?
Upvotes: 13
Views: 10230
Reputation: 21
There is a similar question with this problem including a suggestion for a workaround in the comments. (Is there a way to skip a pipeline when there are markdown changes only?) The rules:when:never
or except:changes
feature doesn't seem to support this at the moment. They opened a ticket with GitLab.
Upvotes: 2
Reputation: 123
If I get you correctly, you need to have except:changes
convention in your CI file.
Take a look at this example. The Job runs in any condition in case the *.md, eslintrc.json, and jsconfig.json have changed. In that case, the pipeline won't run. Check the except-changes stage of the below example.
On the other hand, you can set to run the pipeline in case any js files have changed. Check the * only-changes* stage of the below example.
stages:
- except-changes
- only-changes
ignore-file-changes:
stage: except-changes
script:
- echo "Skip running the pipeline if *.md, eslintrc.json and jsconfig.json has any kind of change."
except:
changes:
- "**/*.md"
- eslintrc.json
- jsconfig.json
- README.md
pass-the-pipeline:
stage: only-changes
script:
- echo "Run only *.js and Dockerfile files has any kind of change."
only:
changes:
- Dockerfile
- "**/*.js"
Upvotes: 3