如何仅在GitlabCi Runner中的HEAD commit上运行管道?

Nao*_*dgi 5 continuous-integration continuous-deployment gitlab gitlab-ci gitlab-ci-runner

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

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

管道运行4个步骤

  • 建立

  • 单元测试

  • 整合测试
  • 质量测试

所有这些流水线需要将近20分钟

并在每次推送到分支时触发管道

有没有一种配置gitlab-runner的方法,如果当前运行的运行器所在的分支的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: {}
Run Code Online (Sandbox Code Playgroud)

在@siloko评论后编辑:

我已经尝试在设置菜单中使用自动取消冗余的未决管道

我想取消正在运行的管道并且不挂起

Nao*_*dgi 5

经过进一步的调查,我发现我的 一台机器上有2个活动运行程序,一个共享运行程序,另一个是特定运行程序,然后,如果我将2个提交一个接一个地推到同一个分支,则两个运行程序都将执行并执行它们。这也解释了为什么

Auto-cancel redundant, pending pipelines 
Run Code Online (Sandbox Code Playgroud)

选项,不起作用,因为它仅在同一跑步者有待处理的工作时才起作用

为解决此问题而采取的操作:注销特定的运行器,仅将计算机与共享运行器一起使用