文章目录

小伯克

GitLab CI 注册 Runner 有更新!

  zousiliang

1.准备好gitlab和token

工程 –> Settings –> CI/CD –> Runners

image

2.注册Runner

Runner需要注册到Gitlab才可以被项目所使用,一个gitlab-ci-multi-runner服务可以注册多个Runner。

sudo gitlab-ci-multi-runner register

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://gitlab.zousiliang.com/
Please enter the gitlab-ci token for this runner:
F4vbKHg1bzZTwLDa3Uxz
Please enter the gitlab-ci description for this runner:
[VM_25_0_centos]: 
Please enter the gitlab-ci tags for this runner (comma separated):
test,demo
Whether to run untagged builds [true/false]:
[false]: 
Whether to lock Runner to current project [true/false]:
[false]: 
Registering runner... succeeded                     runner=F4vbKHg1
Please enter the executor: parallels, virtualbox, docker+machine, docker, docker-ssh, docker-ssh+machine, kubernetes, shell, ssh:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded! 

3.配置构建任务

  1. 在项目根目录添加.gitlab-ci.yml文件

关于该文件的各项配置请见

  1. 示例:
# 定义 stages
stages:
   - build
   - test
   - deploy
   
# 定义 job
job1:
   stage: test
   tags:
     - demo
   script: 
      - echo "I am job1"
      - echo "I am in test stage"
      
# 定义 job
job2:
   stage: build
   tags:
     - demo
   script: 
      - echo "I am job2"
      - echo "I am in build stage"
      
job3:
   stage: deploy
   tags:
     - demo
   script: 
      - echo "I am job3"
      - echo "I am in deploy stage"
  1. 执行结果

image

image

微信 OR 支付宝 扫描二维码
为本文作者 打个赏
pay_weixinpay_weixin