我想通过命令行(例如使用Powershell)从azure devops存储库中定期下载应用程序,但是我不能为此使用git插件。除了git之外还有其他方法吗?
答案 0 :(得分:1)
您可以使用Azure DevOps Rest API-Items - Get(没有git插件)从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)}
答案 1 :(得分:0)
最佳和最简单的选择:
第1步:设置VSTS代理。 第2步:创建构建管道(直到最近才被称为定义)
如果您需要任何帮助,请告诉我。
如果只想使用命令行工具,则可以参考-
https://blog.rsuter.com/script-to-clone-all-git-repositories-from-your-vsts-collection/
答案 2 :(得分:0)
谢谢大家,我做了一些小的更改,而不是在url中使用git,而是将$ uri参数更改为:
const fs = require('fs');
// Define your file paths here
const files = ['./english.json', './russian.json']
// Read contents and parse JSON
const filesWithKeys = files.map(f => ({
name: f,
content: JSON.parse(fs.readFileSync(f, 'utf8'))
}));
// Gather all the keys used in all files in one array
const allKeys = filesWithKeys.map(f => Object.keys(f.content)).flat();
// Find the missing keys by file
const missingKeysByFile = filesWithKeys.map(f => ({
name: f.name,
missingKeys: allKeys.filter(k => !(k in f.content))
})).filter(f => f.missingKeys.length > 0);
// Print the result
missingKeysByFile.forEach(f => {
console.log(`File "${f.name}" is missing keys [ ${f.missingKeys.join(' ')} ]`);
});