Gitlab runner持续集成CI/CD怎么设置标签指定Runner节点执行

搭建Runner参考:
https://www.cnblogs.com/minseo/p/18472436

需求:

  • 未打标签的.gitlab-ci使用默认runner
  • 打标签的.gitlab-ci使用指定的runner
  1. 环境查看
    系统环境
# cat /etc/redhat-release 
Rocky Linux release 9.3 (Blue Onyx)
# uname -a
Linux Rocky9StoneCrm003080 5.14.0-362.18.1.el9_3.0.1.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Feb 11 13:49:23 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

软件环境

# git version
# git version 2.43.5
  1. 配置Runner
# http://ip/admin

新建全局runner
image
不要勾选"运行未打标签的作业"
image
下一步在Runner端执行命令创建runner
3. 编写.gitlab-ci
配置tags即可使用打标签的runner执行作业

# cat .gitlab-ci.yml 
# cat .gitlab-ci.yml 
stages:
  - build
  - test
  - deploy

build:
  tags:
    - prd
  stage: build
  script:
    - echo "Build Test2dd"

test:
  tags:
    - prd
  stage: test
  script:
    - echo "Test"

deploy:
  tags:
    - prd
  stage: deploy
  script:
    - echo "Deploy2a"

image

posted @ 2024-12-20 11:21  minseo  阅读(282)  评论(0)    收藏  举报