如何在推送事件中阻止 gitlab 作业 运行

How can I prevent a gitlab job running on push event

我有一个简单的 gitlab-yaml 文件,我认为它 运行 仅在计划时才可以工作。然而,它在推送事件上也很火。 任何人都可以告诉我指定作业仅在计划时 运行 的正确方法。 这是我的 gitlab-yaml 文件

job:on-schedule:
    only:
        - schedules
        - branches
    script:
        - /usr/local/bin/phpunit -c phpunit_config.xml

谢谢

根据 GitLab 文档,branches 表示 "When a branch is pushed"。

https://docs.gitlab.com/ce/ci/yaml/README.html#only-and-except-simplified

因此,在您的 only: 部分中包含 branches 会导致管道作业也 运行 推送到任何分支。

您可以删除 branches 条目,或者如果您想限制特定分支的推送,您可以扩展分支条目以包含项目和分支名称 (branches@<project>/<branch>)。

我的建议是将您的 YML 减少到:

job:on-schedule:
    only:
        - schedules
    script:
        - /usr/local/bin/phpunit -c phpunit_config.xml