如何 运行 在 Gitlab Ci 运行ner 中仅在 HEAD 上提交管道?

how to run pipeline only on HEAD commit in GitlabCi runner?

我们的存储库上有一个 CI 管道,托管在 gitlab

我们在本地机器上设置 gitlab-runner

流水线运行宁4个步骤

所有这些流水线大约需要 20 分钟

每次推送到分支时都会触发管道

有没有办法配置 gitlab-运行ner,如果 运行ner 当前 运行ning 所在的分支的 HEAD 改变了管道 会自动取消运行吗?因为最新版本才是最重要的

例如在这个运行中,较低的运行是不必要的

gitlab-ci.yml

stages:
  - build
  - unit_tests
  - unit_and_integration_tests
  - quality_tests

build:
  stage: build
  before_script:
    - cd projects/ideology-synapse
  script:
    - mvn compile


unit_and_integration_tests:
  variables:
    GIT_STRATEGY: clone
  stage: unit_and_integration_tests
  only:
    - /^milestone-.*$/
  script:
    - export RUN_ENVIORMENT=GITLAB_CI
    - export MAVEN_OPTS="-Xmx32g"
    - mvn test
    - "cat */target/site/jacoco/index.html"
  cache: {}
  artifacts:
    reports:
      junit:
        - "*/*/*/target/surefire-reports/TEST-*.xml"


unit_tests:
  variables:
    GIT_STRATEGY: clone

  stage: unit_tests
  except:
    - /^milestone-.*$/
  script:
    - export MAVEN_OPTS="-Xmx32g"
    - mvn test
    - "cat */target/site/jacoco/index.html"
  cache: {}
  artifacts:
    reports:
      junit:
        - "*/*/*/target/surefire-reports/TEST-*.xml"

quality_tests:
  variables:
    GIT_STRATEGY: clone
  stage: quality_tests
  only:
    - /^milestone-.*$/
  script:
    - export RUN_ENVIORMENT_EVAL=GITLAB_CI
    - export MAVEN_OPTS="-Xmx32g"
    - mvn test
  cache: {}

在@siloko 评论后编辑:

我已经尝试使用 设置菜单中的自动取消冗余、挂起的管道

我想取消 运行ning 管道而不是挂起

经过进一步调查,我发现我有 2 个 活跃的跑步者 在我的一台机器上 一个 shared runner 和另一个 specific runner 然后如果我将一个 2 commit 一个接一个地推送到同一个分支,两个 runner 都会接受工作并且执行他们。 这也解释了为什么

Auto-cancel redundant, pending pipelines 

选项,没有用,因为它只在同一个跑步者有待处理的工作时才有效

已采取的解决此问题的措施:取消注册特定的运行器并仅将机器与共享运行器一起使用