Gitlab-Runner的一些问题
2025/4/25...大约 2 分钟
Gitlab-Runner的一些问题
Gitlab在mac下环境变量和用户环境变量不一致的问题
相关信息
具体问题表现: 在zsh和bash下可以运行flutter命令,但是在pipline里面会显示flutter: command not found
解决方法
编辑服务的plist文件,新增环境变量,
编辑服务文件 /Users/mac/Library/LaunchAgents/gitlab-runner.plist
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>gitlab-runner</string>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/bin/gitlab-runner</string>
<string>run</string>
<string>--config</string>
<string>/Users/mac/.gitlab-runner/config.toml</string>
<string>--working-directory</string>
<string>/Users/mac</string>
<string>--service</string>
<string>gitlab-runner</string>
<string>--syslog</string>
</array>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/opt/homebrew/bin/:/opt/devTools/flutter/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/devTools/flutter/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin</string>
</dict>
<key>RunAtLoad</key>
<true/>
<key>SessionCreate</key>
<false/>
<key>StandardErrorPath</key>
<string>/Users/mac/gitlab-runner.err.log</string>
<key>StandardOutPath</key>
<string>/Users/mac/gitlab-runner.out.log</string>
</dict>
</plist>
运行命令
先加载配置及然后停止然后启动。(别重启,有概率报错,可能是bug)
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.gitlab-runner.plist
gitlab-runner stop
gitlab-runner start
这样问题就迎刃而解了
Gitlab的CI中日志超过4194304bytes的问题
相关信息
报错信息: 在GitLab面板的job里面显示日志超过4MB无法继续显示更多日志,在写gitlab-ci文件的时候如果遇到报错根本无法调试,这是一个致命的问题。尤其是xcode编译xcarchive然后再打包为ipa文件的时候,日志动不动就是5MB多,下面的文档给出解决方案。
Job's log exceeded limit of 4194304 bytes
问题的原因
根据描述及任务执行状态的初步判断,是因为控制台输出的信息量过大,超出了GitLab Runner默认允许的大小。
解决方法
- 找到gitlab-runner的配置文件,(如果找不到可以使用命令
gitlab-runner list
命令能够看到字段ConfigFile,即为当前使用的runner配置) - 在runner字段下添加output_limit字段设置大小,我这写为1048576大小,也就是最大1G
- 重启runner
在mac中如果使用的是brew安装的runner,默认配置文件在
cat /Users/<用户名>/.gitlab-runner/config.toml
修改好的配置
concurrent = 1
check_interval = 0
shutdown_timeout = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "C4a0-170 Mac Bash 6c32g500g"
url = "http://gitlabr.c4a.com/"
id = 34
token = "EK...BM"
token_obtained_at = 2024-06-06T09:37:57Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "shell"
output_limit = 1048576
[runners.custom_build_dir]
[runners.cache]
MaxUploadedArchiveSize = 0
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
重启runner
gitlab-runner restart
结果
经过验证,完美解决问题。
更新日志
2025/4/25 09:57
查看所有更新日志
6f17d
-于