安裝
安裝教程來自gitlab官網,本文僅演示CentOS系統下安裝gitlab-runner
自動安裝
1.新增gitlab官方儲存庫
1 curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh" | sudo bash
也可以配置yum源安裝
vim /etc/yum.repos.d/gitlab-runner.repo 複製以下內容: [gitlab-runner] name=gitlab-runner baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/yum/el$releasever-$basearch/ repo_gpgcheck=0 gpgcheck=0 enabled=1 gpgkey=https://packages.gitlab.com/gpg.key # 更新快取 yum clean && yum makecache # 安裝最新 yum install -y gitlab-runner
2. 安裝gitlab-runner
2.1 此步驟是透過yum命令安裝最新版本的GItlab Runner,想要安裝指定版本請執行下一步
sudo yum install gitlab-runner
2.2 安裝指定版本
# 透過‘yum install gitlab-runner-×.×.×’指定版本號 sudo yum install gitlab-runner-15.11.0-1
註冊
安裝完成Runner後,我們需要將其註冊到gitlab上
# 執行互動式註冊命令完成註冊 [root@localhost ~]# gitlab-ci-multi-runner register Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/): http://127.0.0.1/ # 你的gitlab地址 Please enter the gitlab-ci token for this runner: *****xxxx***xxxx*** # Token Please enter the gitlab-ci description for this runner: [localhost.localdomain]: focus-runner-des (runner的描述名稱,隨便DIY能有效區分就行) Please enter the gitlab-ci tags for this runner (comma separated):
127.0.0.1
(runner的tags名稱,隨便DIY能有效區分就行) Please enter the executor: docker-ssh, parallels, ssh, virtualbox, kubernetes, docker, shell, docker+machine, docker-ssh+machine: shell (因為想用shell指令碼執行,所以選擇shell,選擇shell的優點是共享伺服器上安裝的java、maven以及docker等應用)