git - 为什么自托管 gitlab 运行程序在克隆存储库并在自托管运行程序上执行作业时遇到问题

标签 git gitlab gitlab-ci gitlab-ci-runner

我目前正在研究 GitLab 运行程序,以更好地了解它们在 CI/CD 管道环境中的工作方式。我按照 GitLab 文档中的说明创建了一个 self 管理的运行器(即我的个人 Windows 笔记本电脑):

  • 安装了 GitLab Runner 可执行文件
  • 在 GitLab 注册我的运行者
  • 为我的玩具项目禁用共享运行者
  • 修改了 toml 文件以使用 powershell 作为 shell 执行器而不是 pwsh

完成这些步骤后,我使用 GitLab Web UI 创建了一个 CI/CD 管道。生成的默认 .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."

基本上只是 echosleep 语句。 Powershell 没有处理不了的事情。

但是,当我使用 GitLab 的 Web UI 手动触发管道时,它会滞后于 build-job,如下所示:

enter image description here

最后超时,如下图:

enter image description here

我的 .gitlab-ci.yml 文件中没有任何内容要求运行者从存储库中克隆任何内容。为什么它要尝试克隆存储库?为什么卡在这一步了?

编辑

提取运行程序日志,如 docs 所示使用 get-winevent 指出以下问题:

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 的一部分

Runner workflow

这个想法是让您的命令(任何命令)在首先克隆的代码库上运行。


关于超时和错误,请参见“Self-signed certificates or custom Certification Authorities all tiers

For connections to the GitLab server: the certificate file can be specified as detailed in the Supported options for self-signed certificates targeting the GitLab server section.

This solves the x509: certificate signed by unknown authority problem when registering a runner.

关于git - 为什么自托管 gitlab 运行程序在克隆存储库并在自托管运行程序上执行作业时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70529254/

相关文章:

git - 如何为默认远程名称设置 gitconfig?

Git 分支 : master vs. origin/master 与 remotes/origin/master

git - Visual Studio - 远程 : HTTP Basic: Access denied Error encountered while cloning the remote repository: Git failed with a fatal error

node.js - 在 package.json 中依赖 GitLab 存储库时获取最新版本

continuous-integration - Gitlab CI多个分支

gitignore 新文件内容不起作用

git - 是否可以使用 bazaar、mercurial 或 git 进行部分克隆/分支?

docker - 冲突。容器名称 "/gitlab-runner"已被容器使用

ruby-on-rails - 用于生产环境的 Rails 5.2 加密凭据

node.js - 找不到 Docker Node flow-bin libelf.so.1 (gitlab ci)