gitlab cicd中獲取tag值的方式

坚强的小蚂蚁發表於2024-03-20

目的:在job的script中獲取標籤的值,方便後面作業

.gitlab-ci.yml檔案如下

# 定義 stages
stages:
  - test


test_nginx:
  stage: test
  tags:
    - test
#   only:
#     refs:
#       - /^aws/
  rules:
    - if: $CI_COMMIT_TAG =~ /^aws/

  script:
    - echo $CI_COMMIT_TAG
    - git diff --name-only HEAD HEAD~1 | grep -q "1.txt" && echo "檔案已更改" || echo "檔案未更改"

相關文章