tiancheng91 / collection

笔记
https://github.com/tiancheng91/collection/issues
21 stars 1 forks source link

gitlab ci push时自动取消运行任务 #56

Open tiancheng91 opened 3 years ago

tiancheng91 commented 3 years ago
check git head:
  stage: pre-build
  before_script:
    - 'FOR /F "tokens=* USEBACKQ" %%F IN (`git rev-parse HEAD`) DO (SET HEAD_COMMIT=%%F)'
  script: 
    - 'IF NOT %HEAD_COMMIT%==%CI_COMMIT_SHA% curl -X POST --HEADER "PRIVATE-TOKEN: %PRIVATE_API_TOKEN%" https://gitlab.com/api/v4/projects/%CI_PROJECT_ID%/pipelines/%CI_PIPELINE_ID%/cancel'
tiancheng91 commented 3 years ago

新版本已支持, 指令文档见

https://docs.gitlab.com/ee/ci/yaml/#interruptible