在VSTS中完成CI / CD流程后,我正在使用SendGrid电子邮件扩展名来触发自定义电子邮件通知。此电子邮件任务中包含HTML内容,其中包括一些使用标准build / release变量(https://docs.microsoft.com/en-us/vsts/build-release/concepts/definitions/build/variables?tabs=批次)。
如何在自定义电子邮件中包括特定版本的相关代码更改,签入注释和链接的工作项?我可以使用任何变量吗?有没有解决的办法?
azure-devops azure-pipelines-build-task azure-pipelines azure-pipelines-release-pipeline azure-devops-rest-api
我想更新构建定义中的变量,但是当它尝试运行时,Invoke-RestMethod我收到以下异常:
Invoke-RestMethod : {"$id":"1","innerException":null,"message":"This request expects an object in the request body,
but the supplied data could not be
deserialized.","typeName":"Microsoft.TeamFoundation.Build.WebApi.RequestContentException,
Microsoft.TeamFoundation.Build2.WebApi, Version=14.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a","typeKey":"RequestContentException","errorCode":0,"eventId":3000}
At D:\a\_temp\231f1be5-edc0-4bd9-a2e4-efd23a8308d1.ps1:42 char:1
+ Invoke-RestMethod -Method Put -Uri "$($projectDef.Url)&api-version=2. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Run Code Online (Sandbox Code Playgroud)
其他一切似乎都正常,我得到了构建定义,我可以更新变量,但是当我尝试使用JSON将PUT放回原位Invoke-RestMethod时失败。
以下是在Powershell内联脚本中运行的已使用代码:
# This script is intended to be used for PowerShell script tasks in VSTS in "inline mode"
$valueName = 'ProjectBuildNumber'
$token = 'MYTOKENCODE'
$uriRoot = $env:SYSTEM_TEAMFOUNDATIONSERVERURI …Run Code Online (Sandbox Code Playgroud) 我已经看到,在REST API的5.0预览中,似乎可以使用以下方法从构建工件中下载特定文件:
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/artifacts?artifactName={artifactName}&fileId={fileId}&fileName={fileName}&api-version=5.0-preview.5
Run Code Online (Sandbox Code Playgroud)
但是,如何列出工件的文件?我不知道要输入什么fileId。
我的用例是在构建过程中作为工件存档的文件夹。我想获取该文件夹中每个文件的下载链接。
在 Azure DevOps 的冲刺板上,任务的“剩余工作”值“汇总”到 PBI 等,并显示在 PBI 卡上。

该值似乎不会保留在 PBI 的“剩余工作”字段中。
如果我尝试使用 REST API 访问该字段
https://dev.azure.com/{myorg}/{project}/_apis/wit/workitems/{id}?fields=Microsoft.VSTS.Scheduling.RemainingWork&api-version=5.0-preview.3
Run Code Online (Sandbox Code Playgroud)
...我得到一个空值
(“字段”属性)
注意:如果我将 URI 中的“字段名称”规范更改为“System.Title”,我会得到正确的值,因此我假设 URI 的格式是正确的。
我的问题是:
例如,PBI 上的“剩余工作”字段是否可以通过 REST API 获得,或者我是否必须迭代所有子任务才能自己计算它?
/杰斯珀
我正在尝试使用 Azure DevOps Rest Api 通过 PowerShell 获取 Azure DevOps 中所有项目的列表。
但是,当我运行该脚本时,它不断返回 100 个项目。当我添加延续标记时,它会循环并返回相同的100 个项目 4 次。所以给了我总共 400 个项目。我们目前有 385 个项目。
$Org = "ORGNAME"
$personalToken = "MYTOKEN"
###################################################
Write-Host "Initialize authentication context" -ForegroundColor Yellow
$token =[System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($personalToken)"))
$header = @{authorization = "Basic $token"}
$projects = $null
function get_projects {
do
{
$uri="https://dev.azure.com/$Org/_apis/projects?continuationToken=$ContinuationToken&api-version=5.1"
$ProjSets=Invoke-WebRequest -Uri $Uri -Method Get -ContentType "application/json" -Headers $header
$continuationToken = $ProjSets.Headers.'x-ms-continuationtoken'
$ProjectSet=$projset.content | ConvertFrom-Json
$projects+=$ProjectSet.value
} while ($continuationToken)
write-host "$continuationToken" -ForegroundColor Cyan
$projects.name
$projects.count
}
get_projects …Run Code Online (Sandbox Code Playgroud) 我目前正在使用 NodeJS 开发一个“发行说明”应用程序,该应用程序调用各种 Azure DevOps REST API 端点来获取基于特定标签的工作项。
我现在所拥有的工作原理如下;
v1.1.v1.1标签匹配的所有工作项。/**
* Function used to fetch initial work items from Azure DevOps that match the provided release number
* @param {String} releaseNumber - the given release number
* @returns {Array} workItems - the initial work items fetched from Azure DevOps
*/
async function fetchWorkItems(releaseNumber) {
console.log('\nFetching work items for given release number...');
let response;
try {
response …Run Code Online (Sandbox Code Playgroud) javascript azure azure-devops azure-pipelines azure-devops-rest-api
我正在尝试使用 Azure Powershell 7 commandlet 获取最新版本的 Canonical UbuntuServer 18.04-LTS。
\n这是我的查询的示例:
\n>> Get-AzVMImage -Location "eastus" -PublisherName "Canonical" -Offer "UbuntuServer" -Skus "18.04-LTS" -Version "latest"\nRun Code Online (Sandbox Code Playgroud)\n身份验证后,我尝试运行该命令行开关,但收到以下错误:
\nGet-AzVMImage:\nLine |\n 2 | Get-AzVMImage -Location "eastus" -PublisherName "Canonical" -Offer "U \xe2\x80\xa6\n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n | The value of parameter version is invalid.\nErrorCode: InvalidParameter\nErrorMessage: The value of parameter version is invalid.\nErrorTarget: version\nStatusCode: 400\nReasonPhrase: Bad Request\nOperationID : 3cf54862-47c7-4092-97e9-20ae6556f37c\nRun Code Online (Sandbox Code Playgroud)\n但是,如果我将 -Version 标志硬编码为已知版本号,如下所示:
\n>> Get-AzVMImage -Location "eastus" -PublisherName "Canonical" -Offer "UbuntuServer" -Skus "18.04-LTS" -Version "18.04.202109280"\n …Run Code Online (Sandbox Code Playgroud) 我们最近使用 Azure DevOps 迁移工具将一些构建迁移到不同的 Azure DevOps 环境。构建管道指向微软托管代理,但由于问题而失败
未指定池
新创建的构建可以在相同的构建配置下正常工作。附加的屏幕截图包含完全相同的示例 yaml,但是迁移的构建因错误而失败,而新创建的构建工作正常。
azure-devops ×10
azure ×2
powershell ×2
azure-pipelines-release-pipeline ×1
javascript ×1
tfs-workitem ×1