Gitlab CI - 如何仅在特定文件集发生更改时触发构建 [英] Gitlab CI - How to trigger a build only if changes happen on particular set of files

查看:12
本文介绍了Gitlab CI - 如何仅在特定文件集发生更改时触发构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Gitlab CI 中,如何仅在特定文件集发生更改时触发构建?

In Gitlab CI, how do you trigger a build only if changes happen on particular set of files?

有没有办法在触发构建时包含或排除某些文件?例如:更新 README.md、.gitignore 文件不应导致构建触发.

Is there a way to either include or exclude certain files from triggering a build? For eg: updating README.md, .gitignore files should not cause a build to trigger.

推荐答案

UPDATE 2

Only/except 似乎是一个不稳定的功能.该文档建议使用 rules:changes 代替:

Only/except seem to be an unstable feature. The doc recommends using rules:changes instead:

job:
  script:
    - build # replace with your build command
  rules:
    - changes:
      - /*.{java, py} # ... or whatever your file extension is

更新 1:

就像评论中提到的Gajus,现在可以了!

Like Gajus mentioned in the comments, it is now possible!

合并请求:https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/21981

文档:https://docs.gitlab.com/ee/ci/yaml/#onlyexcept-basic(感谢 Connor Shea评论中的提示)

Documentation: https://docs.gitlab.com/ee/ci/yaml/#onlyexcept-basic (Thanks to Connor Shea for the tip in the comments)

原帖:

不,不可能——现在不行!

No, it is not possible – not now!

我认为这是您正在寻找的问题:https://gitlab.com/gitlab-org/gitlab-ce/issues/19232 - 这是一个非常高评价的问题(超过 100 次重击).

I think this is the issue you are looking for: https://gitlab.com/gitlab-org/gitlab-ce/issues/19232 – It is a very high rated issue (over 100 thumps-up).

里程碑已更改为 未来 3-6 个月,4 个月前.(https://gitlab.com/gitlab-org/gitlab-ce/问题/19232#note_31943850)我希望我们很快就会看到这个功能.

The milestone has changed to Next 3-6 months, 4 months ago. (https://gitlab.com/gitlab-org/gitlab-ce/issues/19232#note_31943850) I hope we will see this function soon.

这篇关于Gitlab CI - 如何仅在特定文件集发生更改时触发构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆