在服务器上安装 gitlab-runner

使用国内镜像快速安装 GitLab Runner

Debian/Ubuntu 用户安装指南

  1. 添加 GitLab GPG 公钥

    执行以下命令以下载并添加 GitLab 的 GPG 公钥到您的系统中:

    bash 复制代码
    curl -L https://packages.gitlab.com/runner/gitlab-runner/gpgkey | gpg --dearmor > /usr/share/keyrings/gitlab-runner.gpg
  2. 编辑 APT 源列表

    根据您的操作系统版本创建或编辑 /etc/apt/sources.list.d/gitlab-runner.list 文件。

    • 对于 Debian 12 (bookworm),内容如下:

      plaintext 复制代码
      deb [signed-by=/usr/share/keyrings/gitlab-runner.gpg] https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/debian bookworm main
    • 对于 Ubuntu 20.04 LTS (focal),内容如下:

      plaintext 复制代码
      deb [signed-by=/usr/share/keyrings/gitlab-runner.gpg] https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/ubuntu focal main
  3. 更新 APT 包索引并安装 GitLab Runner

    更新本地包索引,并安装 GitLab Runner:

    bash 复制代码
    sudo apt-get update
    bash 复制代码
    sudo apt-get install gitlab-runner

CentOS/RHEL 用户安装指南

  1. 创建 YUM 源配置文件

    新建或编辑 /etc/yum.repos.d/gitlab-runner.repo 文件,内容如下:

    ini 复制代码
    [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
  2. 更新 YUM 缓存并安装 GitLab Runner

    刷新 YUM 包管理器缓存,并安装 GitLab Runner:

    bash 复制代码
    sudo yum makecache
    bash 复制代码
    sudo yum install gitlab-runner

手动离线安装 GitLab Runner 于 GNU/Linux

如果由于某些原因您无法使用 deb/rpm 软件仓库来安装 GitLab Runner,或者您的 GNU/Linux 操作系统不在官方支持列表中,您可以考虑以下方法之一手动安装 GitLab Runner。

使用 deb/rpm 包安装

下载适合您系统的包
  1. 查找最新版本文件名和选项

    访问 GitLab Runner 下载页面,找到最新的文件名和下载链接。

  2. 下载二进制文件

    根据您的系统架构选择合适的版本并下载,可以根据查看服务器或系统架构相关文档确认当前的架构。

    • 对于 Debian 或 Ubuntu:

      替换 ${arch} 为支持的架构之一,如 amd64, arm, arm64

      bash 复制代码
      curl -LJO "https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/ubuntu/pool/noble/main/g/gitlab-runner/gitlab-runner_17.6.0-1_${arch}.deb"

      完整链接如下:
      Ubtntu

      bash 复制代码
      curl -LJO "https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/ubuntu/pool/noble/main/g/gitlab-runner/gitlab-runner_17.6.0-1_amd64.deb"

      Debian

      bash 复制代码
      curl -LJO "https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/ubuntu/pool/noble/main/g/gitlab-runner/gitlab-runner_17.6.0-1_amd64.deb"
    • 对于 CentOS 或 Red Hat Enterprise Linux:

      替换 ${arch} 为支持的架构之一,如 x86_64, aarch64

      根据自己系统版本修改对应的el9-,如 el7-x86_64el9-x86_64

      bash 复制代码
      curl -LJO "https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/yum/el9-${arch}/gitlab-runner-17.6.0-1.${arch}.rpm"

      完整链接如下:
      CentOS yum

      bash 复制代码
      curl -LJO "https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/yum/el9-x86_64/gitlab-runner-17.6.0-1.x86_64.rpm"
    • 对于 FIPS 兼容的 GitLab Runner on RHEL (目前仅支持 amd64):

      bash 复制代码
      curl -LJO "https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/yum/el9-x86_64/gitlab-runner-17.6.0-1.x86_64.rpm"
安装包

根据您的系统执行相应的命令进行安装:

  • 对于 Debian 或 Ubuntu:

    bash 复制代码
    sudo dpkg -i gitlab-runner_<arch>.deb

    如果有依赖项错误,可以尝试修复依赖关系

    bash 复制代码
    sudo apt-get install -f
  • 对于 CentOS 或 Red Hat Enterprise Linux:

    bash 复制代码
    sudo rpm -i gitlab-runner_<arch>.rpm
注册 runner 和升级
  • 升级时,先下载最新版本的包,然后使用 dpkg -irpm -Uvh 命令进行更新。

如果有任何疑问或遇到困难,请查阅官方文档或寻求社区帮助。

相关推荐
宁酱醇6 分钟前
各种各样的bug合集
开发语言·笔记·python·gitlab·bug
极小狐8 小时前
极狐GitLab Git LFS 速率限制如何设置?
运维·git·ssh·gitlab·github
极小狐8 小时前
如何解决极狐GitLab 合并冲突?
人工智能·git·机器学习·gitlab
量子位1 天前
无需数据标注!测试时强化学习,模型数学能力暴增 | 清华 & 上海 AI Lab
人工智能·gitlab·aigc
梁萌2 天前
10-DevOps-Jenkins参数化构建实现多版本发布
运维·gitlab·jenkins·devops·tag
午后书香2 天前
入职前你需要知道的git操作大指南
前端·git·gitlab
亮学长2 天前
GitLab 提交权限校验脚本
gitlab
极小狐2 天前
极狐GitLab 自定义实例级项目模板功能介绍
运维·git·安全·gitlab·极狐gitlab
会写诗的猫3 天前
gitlab-runner 独立服务器部署
gitlab
尖椒土豆sss3 天前
关于GitLab代码仓库工具使用分享
gitlab