我已经设置了 Raspberry PI 并安装了 gitlab-runner 服务。我们还有自己的私人管理的 Gitlab 服务器。我已经注册了一个 gitlab runner 并在我的 Raspberry PI 上启动了它。在我的存储库中,我创建了一个非常简单的 .gitlab-ci.yml 脚本:
stages:
- test
test-job:
stage: test
tags:
- raspberrypi
script:
- echo "This job tests something"
- ls -l
我已经使用以下命令注册了跑步者:
gitlab-runner register --url https://xxx-test.test.lt --token glrt-sauNM8P5zjAZY-C8HYWL
并运行它:
gitlab-runner run
从上面你可以看到,我只是尝试在我的 Raspberry PI gitlab runner 上执行非常基本的 shell 命令。作业失败的原因是:
Running with gitlab-runner 16.7.0 (102c81ba)
on Raspberry PI HIL runner sauNM8P5z, system ID: s_0ae6b2582ae5
Preparing the "shell" executor
00:00
Using Shell (bash) executor...
Preparing environment
00:00
Running on raspberrypi...
Getting source from Git repository
00:01
mkdir: cannot create directory ‘/home/gitlab-runner/builds/sauNM8P5z’: Permission denied
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit status 1
在我的 Raspbery PI 上,我看到以下日志:
lukas@raspberrypi:/home/gitlab-runner $ gitlab-runner run
Runtime platform arch=arm64 os=linux pid=6858 revision=102c81ba version=16.7.0
Starting multi-runner from /home/lukas/.gitlab-runner/config.toml... builds=0 max_builds=0
WARNING: Running in user-mode.
WARNING: Use sudo for system-mode:
WARNING: $ sudo gitlab-runner...
Configuration loaded builds=0 max_builds=1
listen_address not defined, metrics & debug endpoints disabled builds=0 max_builds=1
[session_server].listen_address not defined, session endpoints disabled builds=0 max_builds=1
Initializing executor providers builds=0 max_builds=1
Checking for jobs... received job=783 repo_url=https://xxx-test.test.lt/embeded-programmers/Embedded-FW-Guidelines.git runner=sauNM8P5z
Added job to processing list builds=1 job=783 max_builds=1 project=121 repo_url=https://xxx-test.test.lt/embeded-programmers/Embedded-FW-Guidelines.git
WARNING: Job failed: exit status 1
duration_s=0.256630484 job=783 project=121 runner=sauNM8P2z
Appending trace to coordinator...ok code=202 job=783 job-log=0-919 job-status=running runner=sauNM8P5z sent-log=0-918 status=202 Accepted update-interval=1m0s
Updating job... bytesize=919 checksum=crc32:107c6b65 job=783 runner=sauNM8P5z
Submitting job to coordinator...ok bytesize=919 checksum=crc32:107c6b65 code=200 job=783 job-status= runner=sauNM8P5z update-interval=0s
Removed job from processing list builds=0 job=783 max_builds=1 project=121 repo_url=https://xxx-test.test.lt/embeded-programmers/Embedded-FW-Guidelines.git
Checking for jobs... received job=784 repo_url=https://xxx-test.test.lt/embeded-programmers/Embedded-FW-Guidelines.git runner=sauNM8P5z
Added job to processing list builds=1 job=784 max_builds=1 project=121 repo_url=https://xxx-test.test.lt/embeded-programmers/Embedded-FW-Guidelines.git
WARNING: Job failed: exit status 1
duration_s=0.211797582 job=784 project=121 runner=sauNM8P2z
Appending trace to coordinator...ok code=202 job=784 job-log=0-919 job-status=running runner=sauNM8P5z sent-log=0-918 status=202 Accepted update-interval=1m0s
Updating job... bytesize=919 checksum=crc32:be70e1cb job=784 runner=sauNM8P5z
Submitting job to coordinator...ok bytesize=919 checksum=crc32:be70e1cb code=200 job=784 job-status= runner=sauNM8P5z update-interval=0s
Removed job from processing list builds=0 job=784 max_builds=1 project=121 repo_url=https://xxx-test.test.lt/embeded-programmers/Embedded-FW-Guidelines.git
如果有人能澄清我的 Raspberry PI gitlab 运行程序无法运行 CI/CD 作业的原因,我将不胜感激。
我已经从头开始卸载并安装了 gitlab-runner,这似乎解决了问题。