简体   繁体   English

gitlab 作业正在运行,即使计划管道中没有更改

[英]gitlab job is running even if there is no changes in the schedule pipeline

I set a schedule for my gitlab.yml file to run the pipeline.我为我的 gitlab.yml 文件设置了运行管道的时间表。 In my job I have set rules to run/not run the job.在我的工作中,我设置了运行/不运行工作的规则。 However, in my schedule the job is running no matter if any of my rules met.但是,在我的日程安排中,无论我是否满足任何规则,工作都会运行。

here is the simplified yml file:这是简化的 yml 文件:

stages:
    - build

variables:
    DOCKER_DRIVER: overlay2
    DOCKER_TLS_CERTDIR   : ""

    DOCKER_NETWORK: "gitlab-network"


.docker_dind_service: &docker_dind_service
    services:
        - name: docker:20.10-dind
          command: ["--insecure-registry", "my_server.net:7000"]

docker:custom:
    stage: build
    <<: *docker_dind_service
    tags:
        - docker_runner
    image: docker
    rules:
        - if: '$FORCE_BUILD_DOCKER_IMAGE == "1"'
          when: always
        - changes:
             - Dockerfile
        - when: never
    script:
        - docker build -t my_image .

for the case above, the job is added to the schedule even though there is no change in my Dockerfile.对于上述情况,即使我的 Dockerfile 没有变化,作业也会添加到计划中。 I think I am lost, because when I do changes in my yml file and push it, this job is not added, which is right because there is no change in the Dockerfile.我想我迷路了,因为当我对我的 yml 文件进行更改并推送它时,没有添加此作业,这是正确的,因为 Dockerfile 没有更改。 However, it is running for every scheduled pipeline.但是,它针对每个计划的管道运行。

Apparently according to the Gitlab documentation: https://docs.gitlab.com/ee/ci/yaml/#using-onlychanges-without-pipelines-for-merge-requests显然根据 Gitlab 文档: https://docs.gitlab.com/ee/ci/yaml/#using-onlyrequests-without-pipelines

You should use rules: changes only with branch pipelines or merge request pipelines.您应该使用规则:仅使用分支管道或合并请求管道进行更改。 You can use rules: changes with other pipeline types, but rules: changes always evaluates to true when there is no Git push event.您可以将规则:更改与其他管道类型一起使用,但规则:更改在没有 Git 推送事件时始终评估为真。 Tag pipelines, scheduled pipelines, manual pipelines, and so on do not have a Git push event associated with them.标记管道、计划管道、手动管道等没有与之关联的 Git 推送事件。 A rules: changes job is always added to those pipelines if there is no if that limits the job to branch or merge request pipelines.一条规则:如果没有,则始终将更改作业添加到这些管道中,如果这将作业限制为分支或合并请求管道。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM