gitlab-ci rule 过滤commit message
时间: 2023-08-02 11:09:39 浏览: 48
Yes, you can use the `rules` section in `.gitlab-ci.yml` file to filter jobs based on the commit message. Here's an example:
```
job1:
script:
- echo "This job runs when commit message contains 'deploy'"
rules:
- if: '$CI_COMMIT_MESSAGE =~ /deploy/'
```
In this example, the job `job1` will only run if the commit message contains the word "deploy". The `if` expression in the `rules` section uses a regular expression to match the commit message.
You can also use other operators like `!~` (not match) and `==` (exact match) to filter jobs based on the commit message. For example:
```
job2:
script:
- echo "This job runs when commit message does not contain 'test'"
rules:
- if: '$CI_COMMIT_MESSAGE !~ /test/'
```
In this example, the job `job2` will only run if the commit message does not contain the word "test".