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

查看:193
本文介绍了无法在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中的项目有空格,也许天蓝色中存在与此相关的错误?有人知道任何解决方法吗?

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天全站免登陆