下载从Azure中的DevOps通过命令行应用程序

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

我想下载一个应用程序从蔚蓝DEVOPS通过命令行库(如使用PowerShell的)peridiocally但我不能使用git插件这一点。有没有除了混帐没有办法做到这一点?

git azure tfs azure-devops devops
3个回答
1
投票

您可以从Git仓库文件与Azure的DevOps的REST API - Items - Get(不git的插件)。

https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/items?path={path}&api-version=5.0-preview.1

如果添加参数download(例如:?path={path}&download=true)的文件就会被下载。

所以,你可以用PowerShell脚本文件:

Param(
   [string]$organization= "<Organization-NAME>",
   [string]$projectName = "<PROJECT-NAME>",
   [string]$repoId= "<Repository-ID>",
   [string]$appPath= "<Application-Path>",
   [string]$user = "",
   [string]$token = "<PERSONAL-ACCESS-TOKEN>"
)

# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))

$uri = "https://dev.azure.com/$($organization)/$($project)/_apis/git/repositories/$($repoId)/items?path=$($appPath)&download=true&api-version=5.0-preview.1"

$result = Invoke-RestMethod -Uri $uri -Method Get -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}

0
投票

最好的和最简单的选项是:

第1步:设置VSTS代理。第2步:创建构建流水线(旧称为定义直到最近)

让我知道如果你需要任何帮助。

在情况下,如果你只需要使用命令行工具,那么你就可以refer-

https://blog.rsuter.com/script-to-clone-all-git-repositories-from-your-vsts-collection/


0
投票

谢谢你们,我解决了这个小的变化,而不是在URL使用Git,我改变了$ URI参数:

$uri = "<Azure URL>/<RepoID>/_apis/tfvc/Items?path=<ApplicationPath>&versionDescriptor%5BversionType%5D=5&%24format=zip&api-version=4.1-preview.1"
© www.soinside.com 2019 - 2024. All rights reserved.