返回

安裝Gitlab-runner在linux主機上(centos),並註冊與執行pipeline

安裝Gitlab-runner在linux主機上(centos),並註冊與執行pipeline

目錄

安裝Gitlab Runner

[root@docker ~]# curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash


[root@docker ~]# yum list gitlab-runner --showduplicates | sort -r
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
 * updates: mirror01.idc.hinet.net
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
gitlab-runner.x86_64               16.9.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.9.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.8.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.8.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.7.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.7.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.6.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.6.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.6.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.5.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.4.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.4.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.4.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.3.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.3.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.3.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.2.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.2.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.2.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.1.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.1.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.10.0-1                runner_gitlab-runner
gitlab-runner.x86_64               16.0.3-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.0.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.0.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               16.0.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.9.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.9.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.8.3-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.8.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.8.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.8.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.7.4-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.7.3-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.7.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.7.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.7.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.6.3-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.6.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.6.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.6.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.5.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.5.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.5.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.4.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.4.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.4.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.3.3-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.3.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.3.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.3.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.2.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.2.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.2.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.1.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.11.1-1                runner_gitlab-runner
gitlab-runner.x86_64               15.11.0-1                runner_gitlab-runner
gitlab-runner.x86_64               15.1.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.10.1-1                runner_gitlab-runner
gitlab-runner.x86_64               15.10.0-1                runner_gitlab-runner
gitlab-runner.x86_64               15.0.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               15.0.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.9.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.9.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.9.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.8.3-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.8.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.8.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.7.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.7.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.6.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.6.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.5.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.5.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.5.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.4.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.4.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.4.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.3.4-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.3.3-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.3.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.3.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.2.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.1.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.10.1-1                runner_gitlab-runner
gitlab-runner.x86_64               14.10.0-1                runner_gitlab-runner
gitlab-runner.x86_64               14.0.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               14.0.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.9.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.8.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.7.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.6.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.5.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.4.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.4.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.3.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.3.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.3.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.2.4-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.2.3-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.2.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.2.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.2.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.1.3-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.1.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.12.0-1                runner_gitlab-runner
gitlab-runner.x86_64               13.1.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.11.0-1                runner_gitlab-runner
gitlab-runner.x86_64               13.1.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.10.0-1                runner_gitlab-runner
gitlab-runner.x86_64               13.0.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.0.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               13.0.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               12.9.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               12.9.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               12.8.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               12.7.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               12.7.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               12.6.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               12.5.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               12.4.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               12.4.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               12.3.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               12.2.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               12.10.3-1                runner_gitlab-runner
gitlab-runner.x86_64               12.10.2-1                runner_gitlab-runner
gitlab-runner.x86_64               12.1.0-1                 runner_gitlab-runner
gitlab-runner.x86_64               12.10.1-1                runner_gitlab-runner
gitlab-runner.x86_64               12.10.0-1                runner_gitlab-runner
gitlab-runner.x86_64               12.0.2-1                 runner_gitlab-runner
gitlab-runner.x86_64               12.0.1-1                 runner_gitlab-runner
gitlab-runner.x86_64               12.0.0-1                 runner_gitlab-runner



[root@docker ~]# sudo yum install gitlab-runner-12.4.0-1

Gitlab Runner註冊

進到已安裝的Gitlab管理頁面,點選Runners,可以看到URL和token

進行註冊

[root@docker ~]# gitlab-runner register
Runtime platform                                    arch=amd64 os=linux pid=15214 revision=1564076b version=12.4.0
Running in system-mode.

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://192.168.1.55/


Please enter the gitlab-ci token for this runner:
BmSnpmSVS3CMxQ9Vyiki


Please enter the gitlab-ci description for this runner:
[docker]: devops-service-runner


Please enter the gitlab-ci tags for this runner (comma separated):
build
Registering runner... succeeded                     runner=BmSnpmSV


Please enter the executor: parallels, virtualbox, docker-ssh+machine, kubernetes, custom, docker, docker-ssh, shell, ssh, docker+machine:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!

此時可以回到Gitlab頁面,查看runner是否已註冊

確定已註冊,調整Runner設定,並分配給Project使用

這裡可以看到,我分配給demo-ci-service project使用

測試 Runner 執行pipeline

在專案新增一個名為.gitlab-ci.yml的檔案

before_script:
  - echo "before-script!!"

variables:
  DOMAIN: example.com
  
stages:
  - build
  - test
  - codescan
  - deploy

build:
  before_script:
    - echo "before-script in job"
  stage: build
  script:
    - echo "mvn clean "
    - echo "mvn install"
    - echo "$DOMAIN"
  after_script:
    - echo "after script in buildjob"

unittest:
  stage: test
  script:
    - echo "run test"

deploy:
  stage: deploy
  script:
    - echo "hello deploy"
    - sleep 2;
  
codescan:
  stage: codescan
  script:
    - echo "codescan"
    - sleep 5;
 
after_script:
  - echo "after-script"
  - ech

保存並執行pipeline

可以看到,執行完成

可以看到,確定是使用,我們分配的runner執行

Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
使用 Hugo 建立
主題 StackJimmy 設計
發表了128篇文章 · 總計63.96k字
本站已運行
·