1清蚀、下載
curl -LJO "https://gitlab-runner-downloads.s3.amazonaws.com/latest/deb/gitlab-runner_amd64.deb"
2蹲嚣、安裝
dpkg -i gitlab-runner_amd64.deb
3递瑰、更新
dpkg -i gitlab-runner_amd64.deb
4、注冊
sudo gitlab-runner register
- url
- token
- 描述
- 標簽隙畜,不設置全局可用
- 執(zhí)行方式:shell
錯誤解決方法
-
ERROR: Job failed (system failure): prepare environment: exit status 1. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information
原因:Ubuntu 20.04版本在執(zhí)行ci時會出現(xiàn)此錯誤抖部,解決方法是刪除工作目錄下的.bash_logout文件
# 查看gitlab-runner配置 jack@k8smaster:~$ ps aux | grep gitlab-runner root 314163 0.2 0.3 143980 30740 ? Ssl 08:06 0:01 /usr/bin/gitlab-runner run --working-directory /home/gitlab-runner --config /etc/gitlab-runner/config.toml --service gitlab-runner --user gitlab-runner jack 320030 0.0 0.0 6432 2624 pts/0 S+ 08:14 0:00 grep --color=auto gitlab-runner # 刪除.bash_logout jack@k8smaster:~$ sudo rm -r /home/gitlab-runner/.bash_logout
-
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.24/auth: dial unix /var/run/docker.sock: connect: permission denied
原因:gitlab-runner賬號權限不足,不能訪問/var/run/docker.sock议惰。
# 將gitlab-runner用戶加入docker組 [root@gitlab-runner ~]# usermod -aG docker gitlab-runner # 查看 [root@gitlab-runner ~]# groups gitlab-runner
-
執(zhí)行kubectl命令報錯:The connection to the server localhost:8080 was refused - did you specify the right host or port?
原因:gitlab-runner賬號沒有kubeadm配置文件慎颗。
mkdir -p /home/gitlab-runner/.kube sudo cp -i /etc/kubernetes/admin.conf /home/gitlab-runner/.kube/config sudo chown 755 /home/gitlab-runner/.kube/config
-
啟用多分支報錯:Error: Cannot perform an interactive login from a non TTY device
原因:變量受到保護,而除master分支默認被保護之外言询,其他分支未設置保護俯萎,無法讀取被保護的變量
將分支添加到受保護的分支下面; 設置->倉庫->Protected branches,選擇要保護的分支运杭。