运行 Gitlab 构建时发生访问被拒绝错误

运行 Gitlab 构建时发生访问被拒绝错误

我正在从 Docker 容器运行自托管 Gitlab 服务器。对于 CI/CD,我也在 docker 容器中运行 gitlab-runner。我的 Gitlab 版本是 V16.5.2。

我的运行器设置为使用 dockerized Maven 来构建 Spring Boot 应用程序(换句话说,运行器有一个“docker”的执行器)。gitlab-ci.yml 文件包含以下内容:

variables:
  MAVEN_OPTS: -Dmaven.repo.local=.m2/repository

image: maven:latest

stages:
    - build

cache:
  paths:
    - .m2/repository
    - target

build_job:
  stage: build
  tags:
    - defender 

  script: 
    - echo "Maven compile started"
    - "mvn compile"
    

尝试构建时,我不断遇到失败。我的构建尝试日志如下:

section_start:1699378398:prepare_executor
[0K[0K[36;1mPreparing the "docker" executor[0;m[0;m
[0KUsing Docker executor with image maven:latest ...[0;m
[0KPulling docker image maven:latest ...[0;m
[0KUsing docker image sha256:6f90e67c6517ddbfbd701490443ca2645964d5a4da0382e9c144ecfaaa972d4b for maven:latest with digest maven@sha256:e0900e5953fddc181fdbe449ba8c27f124470fb545fbbb29f39f50d6093c9b18 ...[0;m
section_end:1699378401:prepare_executor
[0Ksection_start:1699378401:prepare_script
[0K[0K[36;1mPreparing environment[0;m[0;m
Running on runner-siwnpzrb-project-19-concurrent-0 via c734e0f780f9...
section_end:1699378402:prepare_script
[0Ksection_start:1699378402:get_sources
[0K[0K[36;1mGetting source from Git repository[0;m[0;m
[32;1mFetching changes with git depth set to 20...[0;m
Reinitialized existing Git repository in /builds/research/project-06/project-06d/configsrv/.git/
remote: HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2FA enabled and you must use a personal access token instead of a password. See https://git.solishome.net/help/topics/git/troubleshooting_git#error-on-git-fetch-http-basic-access-denied
fatal: Authentication failed for 'http://git.solishome.net/research/project-06/project-06d/configsrv.git/'
section_end:1699378403:get_sources
[0Ksection_start:1699378403:cleanup_file_variables
[0K[0K[36;1mCleaning up project directory and file based variables[0;m[0;m
section_end:1699378404:cleanup_file_variables
[0K[31;1mERROR: Job failed: exit code 1
[0;m

我没有在我的运行器上使用双因素身份验证。运行器已使用我的 Gitlab 实例提供的注册令牌正确注册。

我注意到一件奇怪的事情,虽然我配置为使用 https 访问我的 Gitlab 实例,但身份验证失败是使用 http 进行访问。这是问题的一部分吗?

有人能告诉我如何才能阻止这些身份验证失败吗?

答案1

从错误消息中的链接: https://docs.gitlab.com/16.5/ee/user/profile/account/two_factor_authentication.html#troubleshooting

您是否已证实这些也不适用于您?

You do not have 2FA enabled and have sent an incorrect username or password with your request.

You do not have 2FA enabled but an administrator has enabled the enforce 2FA for all users setting.

You do not have 2FA enabled, but an administrator has disabled the password authentication enabled for Git over HTTP(S) setting.

您还可以尝试将 CI_DEBUG_TRACE 设置为 true 作为管道变量来运行管道,它将显示克隆过程的调试日志,请记住,如果您有未屏蔽的凭据或其他环境机密,它们可能是可见的,参考: https://docs.gitlab.com/ee/ci/variables/#enable-debug-logging

相关内容