无法在Azure DevOps管道中的命令行脚本任务中克隆git存储库

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

我创建了azure devops管道,我需要从另一个git存储库下载代码。根据推荐的解决方案,我已经在某处读过,我使用git clone命令添加了一个命令行脚本任务。不幸的是,这不起作用。

我得到的错误是:remote:TF200016:以下项目不存在:My0Test0Project。验证项目的名称是否正确,以及项目是否存在于指定的Azure DevOps服务器上。致命:未找到存储库'https://dev.azure.com/myCompany/My0Test0Project/_git/Service.Azure.Core/'

我在Azure中的项目有空格,也许有一个与天蓝色相关的错误?有人知道任何变通方法吗?

这是我已经尝试过的一些代码:

git -c http.extraheader="AUTHORIZATION: Basic bXl1c2VyOmxtNjRpYTYzb283bW1iYXp1bnpzMml2eWxzbXZoZXE2azR1b3V2bXdzbnl5b3R5YWlnY2E=" clone https://dev.azure.com/myCompany/My%20Test%20Project/_git/Service.Azure.Core
git -c http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" clone https://dev.azure.com/myCompany/My%20Test%20Project/_git/Service.Azure.Core
git clone https://oauth:lm64ia63oo7mmbazunzs2ivylsmvheq6k4uouvmwsnyyotyaigca@dev.azure.com/myCompany/My%20Test%20Project/_git/Service.Azure.Core
git clone https://test:$(System.AccessToken)@dev.azure.com/myCompany/My%20Test%20Project/_git/Service.Azure.Core
azure-devops azure-pipelines
2个回答
0
投票

您可以尝试将命令行任务更改为此类任务吗?

git clone --single-branch --branch $(branchName) https://$(gitUserName):$(gitPassword)@dev.azure.com/myCompany/My%20Test%20Project/_git

其中$(gitUserName)和$(gitPassword)在Alternate git credentials中配置为your Azure DevOps account

还想问一下git存储库URL的结尾:“... / _ git / Service.Azure.Core”,你试图指定要克隆的文件夹或工作目录?您也可以尝试以前的代码而不用结束,只需https://dev.azure.com/myCompany/My%20Test%20Project/_git


0
投票

我从Powershell任务尝试了这个,它的工作非常简单

- powershell: |
   git config user.email "$(Build.RequestedForEmail)"
   git config user.name "$(Build.RequestedFor)"
   git -c http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)"  clone  https://<org_Name>.visualstudio.com/<project_name>/_git/<repository_name>;
  displayName: "<your task display name>"
© www.soinside.com 2019 - 2024. All rights reserved.