Gitlab CI-如何列出更改并将其放入管道变量的目录
是否可以自动检测包含在提交中具有更改的文件的顶级目录,并将其添加到我可以在另一个阶段使用的变量?
假设我有一个项目:
- folder1/file [1-3] .txt
- folder2/folder3/file4.txt
如果提交提交file1.txt,我想定义一个等于“ folder1”的变量。
variables:
- $MYVAR == "folder1"
如果提交修改File4.txt,我想定义一个等于“ folder2”的变量。
variables:
- $MYVAR == "folder2"
在不同文件夹中对多个文件的修改不应发生。
然后在管道的另一个阶段使用该变量:
MEP:
stage: deploy
script:
- echo $MYVAR
这是可能的吗?
Is it possible to automatically detect the top-level directory that contains file that have changes in the commit, and add this to a variable that i can use in another stage ?
Let's say i have a project with :
- folder1/file[1-3].txt
- folder2/folder3/file4.txt
If the commit modify file1.txt, i would like to define a variable that is equal to "folder1".
variables:
- $MYVAR == "folder1"
If the commit modify file4.txt, i would like to define a variable that is equal to "folder2".
variables:
- $MYVAR == "folder2"
Modification to multiple file in different folder should not happen.
And then use that variable in another stage of the pipeline :
MEP:
stage: deploy
script:
- echo $MYVAR
Would that be possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以有条件地使用
规则定义变量:变量:
- 规则可以使用规则:更改:
来确定特定文件是否更改。请记住,只有1个规则匹配的任何给定的工作/管道。
You can conditionally define variables with
rules:variables:
-- rules can userules:changes:
to determine if particular files changed.Keep in mind only 1 rule matches for any given job/pipeline.