gitlab cicd中获取tag值的方式

目的:在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 "文件未更改"

 

posted @ 2024-03-20 10:41  坚强的小蚂蚁  阅读(63)  评论(0编辑  收藏  举报