无法在 Azure DevOps Pipelines 的命令行脚本任务中克隆 git 存储库 [英] Cannot clone git repository in command line script task in Azure DevOps Pipelines

查看:29
本文介绍了无法在 Azure DevOps Pipelines 的命令行脚本任务中克隆 git 存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I created azure devops pipeline where I need to download code from another git repository. As per recommended solution I've read somewhere, I added a command line script task with git clone command. Unfortunatelly this doesn't work.

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

The error that I get is: remote: TF200016: The following project does not exist: My0Test0Project. Verify that the name of the project is correct and that the project exists on the specified Azure DevOps Server. fatal: repository 'https://dev.azure.com/myCompany/My0Test0Project/_git/Service.Azure.Core/' not found

我在 Azure 中的项目有空格,也许 azure 中存在与此相关的错误?有人知道任何解决方法吗?

My project in Azure has spaces, maybe there is a bug in azure related to that? Does anybody knows any workarounds?

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

This is some code that I have tried already:

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 可以访问外部存储库.(您的凭据需要访问该存储库)

The reason is because you need to add the system access token so that Azure can have access to the external repo. (your credentials need access to that repo)

注意:

我将 URL 用引号括起来以转义 URL 字符串中的 % 符号,否则 Powershell 会将它们视为变量.

I wrapped my URL in quotes to escape the % signs in the URL string because Powershell treats those as variables otherwise.

- powershell: |
    git clone -c http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" "https://{YOUR PIPELINE URL}"
    displayName: '{YOUR PIPELINE NAME}'

这篇关于无法在 Azure DevOps Pipelines 的命令行脚本任务中克隆 git 存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆