背景
给一台阿里云的云服务器安装gitlab-runner
的时候遇到了个404的错误,使用的安装命令为curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh | sudo bash
,错误提示为
curl: (22) The requested URL returned error: 404 Not Found
Unable to download repo config from: https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/config_file.repo?os=alinux&dist=2&source=script
This usually happens if your operating system is not supported by
packagecloud.io, or this script's OS detection failed.
You can override the OS detection by setting os= and dist= prior to running this script.
You can find a list of supported OSes and distributions on our website: https://packages.gitlab.com/docs#os_distro_version
问题分析
可以看到,错误提示是不支持当前的系统,因为服务器安装的为阿里云专属镜像AliyunOS,故安装脚本识别的时候会将变量设置为os=alinux
,但脚本里没有处理该os,故只能走unknown_os
的方法,感兴趣的可以点击这里直接查看安装脚本的源码。
解决方法
因为服务器安装的是Alibaba Cloud Linux 2.1903 LTS 64位
,其内核是基于CentOS7的,所以我们手动指定即可,命令如下
wget https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh
sudo os=el dist=7 bash ./script.rpm.sh