为什么自托管GitLab Runner在克隆repo和在自托管Runner上执行作业时遇到问题 [英] Why is self-hosted gitlab runner having trouble cloning repo and executing the job on self-hosted runner
问题描述
我目前正在尝试GitLab运行程序,以便更好地理解他们如何在CI/CD管道的上下文中工作。我按照GitLab文档中的说明创建了自我管理跑步器(即我的个人Windows笔记本电脑):
- 已安装GitLab Runner可执行文件
- 将我的跑步者注册到GitLab
- 为我的玩具项目禁用共享跑步器
- 已修改
toml
文件以使用powershell
而不是pwsh
作为shell执行器
.gitlab-ci.yml
文件如下所示:
stages: # List of stages for jobs, and their order of execution
- build
- test
- deploy
build-job: # This job runs in the build stage, which runs first.
stage: build
script:
- echo "Compiling the code..."
- echo "Compile complete."
unit-test-job: # This job runs in the test stage.
stage: test # It only starts when the job in the build stage completes successfully.
script:
- echo "Running unit tests... This will take about 60 seconds."
- sleep 60
- echo "Code coverage is 90%"
lint-test-job: # This job also runs in the test stage.
stage: test # It can run at the same time as unit-test-job (in parallel).
script:
- echo "Linting code... This will take about 10 seconds."
- sleep 10
- echo "No lint issues found."
deploy-job: # This job runs in the deploy stage.
stage: deploy # It only runs when *both* jobs in the test stage complete successfully.
script:
- echo "Deploying application..."
- echo "Application successfully deployed."
基本上只有echo
和sleep
语句。没有PowerShell处理不了的东西。
但是,当我使用GitLab的Web UI手动触发管道时,它滞后于build-job
,如下所示:
最后超时,如下所示:
我的.gitlab-ci.yml
文件中没有任何内容要求运行者从存储库克隆任何内容。不管怎样,它为什么要试图克隆回购呢?为什么卡在这个台阶上?
编辑
使用get-winevent
提取docs指示的Runner日志表明存在以下问题:
WARNING: Checking for jobs... failed
runner=WazTRLts status=couldn't execute POST against https://gitlab.com/api/v4/jobs/request: Post https://gitlab.com/api/v4/jobs/request: x509: certificate signed by unknown authority
这可能有助于理解为什么会发生超时?我如何解决此问题?
推荐答案
属于任何runner (self-managed or not) workflow
我们的想法是让您的命令(任何命令)在您的代码库上操作,代码库首先被克隆。
有关超时和错误,请参阅";Self-signed certificates or custom Certification Authorities all tiers";
对于连接到GitLab服务器:可以按照Supported options for self-signed certificates targeting the GitLab server section中的详细说明指定证书文件。
这解决了注册跑步者时的
x509: certificate signed by unknown authority
问题。
这篇关于为什么自托管GitLab Runner在克隆repo和在自托管Runner上执行作业时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!