Gitlab CI如何使用规则语法忽略目录? [英] Gitlab CI how to ignore directory using rules syntax?
问题描述
我能够使用以下语法忽略目录、文件更改.
I was able to ignore directory, file changes using the following syntax.
build:
script: npm run build
except:
changes:
- "*.md"
- "src/**/*.ts"
使用此配置,build
作业将运行,但 git 更改仅包含 *.md
扩展文件或 *.ts
文件code>src 目录.他们被忽略了.
With this configuration build
job is going to run except git changes include only *.md
extension file or *.ts
files in src
directory. They're ignored.
但后来他们弃用了这种 only:changes
, except:changes
语法,并警告改用 rules
语法.不幸的是,我似乎找不到如何使用这种新语法忽略目录、文件更改.
But then they deprecated this only:changes
, except:changes
syntax and warned to use rules
syntax instead. Unfortunately, I cannot seem to find how to ignore directory, file changes using this new syntax.
推荐答案
基于rules: changes
的文档,似乎 when: never
必须与 rules: changes
语法一起使用.像下面这样:
Based on documents of rules: changes
, it seems when: never
must be used with rules: changes
syntax. Like the following:
build:
script: npm run build
rules:
- changes:
- "*.md"
- "src/**/*.ts"
when: never
- when: always
如果存储库中更改的路径与上述正则表达式匹配,则该作业将不会添加到任何管道中.在其他情况下,作业将始终由管道运行.
If changed paths in the repository match above regular expressions then the job will not be added to any pipeline. In other cases the job always will be run by pipelines.
这篇关于Gitlab CI如何使用规则语法忽略目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!