参考官网:
gitlab-runer装起来
Gitlab Runner可以安装在以下系统中:GNU/Linux,macOS,FreeBSD和Windows。此处介绍下linux三种安装方式:使用Docker安装,下载二进制运行文件手动安装,或者使用rpm/deb/apt之类的包管理工具。接下来我们将介绍其对应的安装方法,图示例运行在Ubuntu16.04。
本章讲解如何在Docker容器中运行 GitLab Runner
假设GitLab Runner Docker镜像已经启动。
通常情况下,所有GitLab Runner命令的执行方式如下:
gitlab-runner [Runner相关的指令或者选项参数]
在Docker模式的GitLab,执行方式如下
docker exec [选择指定docker镜像选项参数] [镜像名] gitlab-runner [Runner相关的指令或者选项参数]
例如,对于已经启动的GitLab Runner镜像,使用GitLab Runner指令,获取顶级帮助信息,执行方式如下:
sudo docker exec -it gitlab-runner gitlab-runner --help
NAME:
gitlab-runner - a GitLab Runner
USAGE:
gitlab-runner [global options] command [command options] [arguments...]
VERSION:
11.5.1 (7f00c780)
(...)
简而言之,在gitlab-runner命令前面添加 docker run [docker options] gitlab-runner,即可生成Docker版本的命令,其中gitlab-runner为镜像名称。唯一的区别就是Docker版本的gitlab-runner指令是执行在Docker容器里的。
curl -sSL https://get.docker.com/ | sh
docker run -d --name gitlab-runner --restart always \
-v /srv/gitlab-runner/config:/etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:latest
docker pull gitlab/gitlab-runner:latest
docker stop gitlab-runner && docker rm gitlab-runner
docker run -d --name gitlab-runner --restart always \
-v /srv/gitlab-runner/config:/etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:latest
# Linux x86-64
sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
# Linux x86
sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-386
# Linux arm
sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-arm
sudo chmod +x /usr/local/bin/gitlab-runner
sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
sudo gitlab-runner start
6. 注册Runner,绑定gitlab代码分支和gitlab-runner
sudo gitlab-runner stop
sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-386
sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
sudo chmod +x /usr/local/bin/gitlab-runner
sudo gitlab-runner start
# For Debian/Ubuntu/Mint
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
# For RHEL/CentOS/Fedora
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash
# For Debian/Ubuntu/Mint
sudo apt-get install gitlab-runner
# For RHEL/CentOS/Fedora
sudo yum install gitlab-runner
# for DEB based systems
apt-cache madison gitlab-runner
sudo apt-get install gitlab-runner=11.6.0
# for RPM based systems
yum list gitlab-runner --showduplicates | sort -r
sudo yum install gitlab-runner-10.0.0-1
确保已经添加GitLab官方仓库,升级操作很简单:
# For Debian/Ubuntu/Mint
sudo apt-get update
sudo apt-get install gitlab-runner
# For RHEL/CentOS/Fedora
sudo yum update
sudo yum install gitlab-runner