简体   繁体   中英

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. 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:

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. 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. 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

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. Tag pipelines, scheduled pipelines, manual pipelines, and so on do not have a Git push event associated with them. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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