Azure DevOps 和 Git Fetch 因错误而失败

问题描述 投票:0回答:2

我已经创建了 Azure DevOps 管道,但它在 git checkout 上失败了,

Starting: Checkout repository@Dev to s
==============================================================================
Task         : Get sources
Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version      : 1.0.0
Author       : Microsoft
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
==============================================================================
Syncing repository: repository (ExternalGit)
Prepending Path environment variable with directory containing 'git.exe'.
git version
git version 2.39.1.windows.1
git lfs version
git-lfs/2.13.3 (GitHub; windows amd64; go 1.16.2; git a5e65851)
git init "D:\a\1\s"
Initialized empty Git repository in D:/a/1/s/.git/
git remote add origin http://gitlab.mycompany.net/mycompany/myapp.git
git config gc.auto 0
git config --get-all http.http://gitlab.mycompany.net/mycompany/myapp.git.extraheader
git config --get-all http.extraheader
git config --get-regexp .*extraheader
git config --get-all http.proxy
git config http.version HTTP/1.1
git remote set-url origin http://***:***@gitlab.mycompany.net/mycompany/myapp.git
git remote set-url --push origin http://***:***@gitlab.mycompany.net/mycompany/myapp.git
git fetch --force --no-tags --prune --prune-tags --progress --no-recurse-submodules origin
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 http://gitlab.mycompany.net/help/topics/git/troubleshooting_git#error-on-git-fetch-http-basic-access-denied
fatal: Authentication failed for 'http://gitlab.mycompany.net/mycompany/myapp.git/'
##[warning]Git fetch failed with exit code 128, back off 6.062 seconds before retry.
git fetch --force --no-tags --prune --prune-tags --progress --no-recurse-submodules origin
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 http://gitlab.mycompany.net/help/topics/git/troubleshooting_git#error-on-git-fetch-http-basic-access-denied

但是,如果我在任何命令行中运行相同的命令,它都可以正常工作,

C:\Users\Imran\repo>git version
git version 2.32.0.windows.2

C:\Users\Imran\repo>git lfs version
git-lfs/2.13.3 (GitHub; windows amd64; go 1.16.2; git a5e65851)

C:\Users\Imran\repo>git init
Initialized empty Git repository in C:/Users//Imran/repo/.git/

C:\Users\Imran\repo>git remote add origin http://gitlab.mycompany.net/mycompany/myapp.git

C:\Users\Imran\repo>git config gc.auto 0

C:\Users\Imran\repo>git config --get-all http.http://gitlab.mycompany.net/mycompany/myapp.git.extraheader

C:\Users\Imran\repo>git config --get-all http.extraheader

C:\Users\Imran\repo>git config --get-regexp .*extraheader

C:\Users\Imran\repo>git config --get-all http.proxy

C:\Users\Imran\repo>git config http.version HTTP/1.1

C:\Users\Imran\repo>git remote set-url origin http://username:[email protected]/mycompany/myapp.git

C:\Users\Imran\repo>git remote set-url --push origin http://username:[email protected]/mycompany/myapp.git

C:\Users\Imran\repo>git fetch --force --no-tags --prune --prune-tags --progress --no-recurse-submodules origin
warning: redirecting to https://gitlab.mycompany.net/mycompany/myapp.git/
remote: Enumerating objects: 54107, done.
remote: Counting objects: 100% (1844/1844), done.
remote: Compressing objects: 100% (138/138), done.

我选择了 MAC,它可以工作,但在 Windows 上显示错误。

git azure-devops gitlab
2个回答
1
投票

我发现当我复制gitlab repo URL时,它包括http。我将 URL 更改为 https 并且成功了。


0
投票

在从 github 获取 git 存储库到 azure 时使用 https 而不是 http。

© www.soinside.com 2019 - 2024. All rights reserved.