Tar*_*ras 5 azure-devops azure-pipelines
我创建了 azure devops 管道,我需要从另一个 git 存储库下载代码。根据我在某处读过的推荐解决方案,我使用 git clone 命令添加了一个命令行脚本任务。不幸的是,这不起作用。
我得到的错误是:远程:TF200016:以下项目不存在:My0Test0Project。验证项目名称是否正确以及该项目是否存在于指定的 Azure DevOps 服务器上。致命:存储库 ' https://dev.azure.com/myCompany/My0Test0Project/_git/Service.Azure.Core/ ' 未找到
我在 Azure 中的项目有空间,也许 azure 中存在与此相关的错误?有人知道任何解决方法吗?
这是我已经尝试过的一些代码:
git -c http.extraheader="AUTHORIZATION: Basic bXl1c2VyOmxtNjRpYTYzb283bW1iYXp1bnpzMml2eWxzbXZoZXE2azR1b3V2bXdzbnl5b3R5YWlnY2E=" clone https://dev.azure.com/myCompany/My%20Test%20Project/_git/Service.Azure.Core
Run Code Online (Sandbox Code Playgroud)
git -c http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" clone https://dev.azure.com/myCompany/My%20Test%20Project/_git/Service.Azure.Core
Run Code Online (Sandbox Code Playgroud)
git clone https://oauth:lm64ia63oo7mmbazunzs2ivylsmvheq6k4uouvmwsnyyotyaigca@dev.azure.com/myCompany/My%20Test%20Project/_git/Service.Azure.Core
Run Code Online (Sandbox Code Playgroud)
git clone https://test:$(System.AccessToken)@dev.azure.com/myCompany/My%20Test%20Project/_git/Service.Azure.Core
Run Code Online (Sandbox Code Playgroud)
小智 5
原因是您需要添加系统访问令牌,以便 Azure 可以访问外部存储库。(您的凭据需要访问该存储库)
笔记:
我将 URL 括在引号中以转义 URL 字符串中的 % 符号,因为 Powershell 会将这些符号视为变量。
- powershell: |
git clone -c http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" "https://{YOUR PIPELINE URL}"
displayName: '{YOUR PIPELINE NAME}'
Run Code Online (Sandbox Code Playgroud)
小智 5
我在 bash 脚本中遇到了同样的问题,并通过使用 转义字符来解决%它%%。
所以,你可以使用这个:
git clone https://test:$(System.AccessToken)@dev.azure.com/myCompany/My%%20Test%%20Project/_git/Service.Azure.Core
小智 0
您可以尝试将命令行任务更改为类似这样的任务吗?
git clone --single-branch --branch $(branchName) https://$(gitUserName):$(gitPassword)@dev.azure.com/myCompany/My%20Test%20Project/_git
Run Code Online (Sandbox Code Playgroud)
其中 $(gitUserName) 和 $(gitPassword)在 Azure DevOps 帐户中配置为备用 git 凭据。
还想询问 git 存储库 URL 的结尾:“.../_git/Service.Azure.Core”,您正在尝试指定要克隆的文件夹或工作目录?您也可以尝试以前的代码而不用那个结尾,只需
https://dev.azure.com/myCompany/My%20Test%20Project/_git
| 归档时间: |
|
| 查看次数: |
4318 次 |
| 最近记录: |