当通过REST API排队Azure DevOps Pipeline版本时,是否可以更改"[user]的手动版本"?文本? [英] When queuing an Azure DevOps Pipeline build via the REST API, is it possible to change the "Manual build for [user]" text?
本文介绍了当通过REST API排队Azure DevOps Pipeline版本时,是否可以更改"[user]的手动版本"?文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用
解决方案
您可以像这样更改描述文本:
Param([string] $ vstsAccount =软件",[string] $ projectName ="project",[string] $ definitionId ="895",[string] $ keepForever ="true",[string] $ personalAccessToken ="xxxxxx")#Base64编码个人访问令牌(PAT)$ headers = @ {Authorization ='Basic'+ [Convert] :: ToBase64String([Text.Encoding] :: ASCII.GetBytes(:$($ personalAccessToken)"))}}#构造REST URL$ uri ="https://vsrm.dev.azure.com/$vstsAccount/$projectName/_apis/release/releases?api-version=5.0-preview.8"写主机"Uri:" $ uri$ params =@{"definitionId":$ definitionId,"description":从PowerShell脚本创建发行版",工件":[],"isDraft":否,"reason":"VSTS触发器","manualEnvironments":null,"environmentsMetadata":null,属性":null,变量":null}"@写主机请求正文:" $ params#调用REST调用并捕获结果$ result = Invoke-RestMethod -Uri $ uri -Method POST -Body $ params -Headers $ headers -ContentType"application/json"-详细-Debug写主机结果:" $ result#此调用只能提供一个结果如果($ result.count -eq 0){写主机无法找到发布定义ID $ definitionId"}别的{写主机成功触发了VSTS发布作业!!!"}
When I queue a build in Azure DevOps Pipelines using the REST API, the build shows up in the build list as Manual build for [user]
where [user]
is the name of the user tied to the token with which the API request was made. Is it possible to replace this with custom text (e.g., Build for PR#1234
or some such)?
edit: Here's a screenshot of the web UI build list with the Manual build for [user]
text that I'm looking to change:
解决方案
You can change the description text like this :
Param(
[string]$vstsAccount = "software",
[string]$projectName = "project",
[string]$definitionId = "895",
[string]$keepForever = "true",
[string]$personalAccessToken = "xxxxxx"
)
# Base64-encodes the Personal Access Token (PAT)
$headers = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($personalAccessToken)")) }
# Construct the REST URL
$uri = "https://vsrm.dev.azure.com/$vstsAccount/$projectName/_apis/release/releases?api-version=5.0-preview.8"
Write-Host "Uri :" $uri
$params =
@"
{
"definitionId": $definitionId,
"description": "Create Release from PowerShell Script",
"artifacts": [],
"isDraft": false,
"reason": "VSTS Trigger",
"manualEnvironments": null,
"environmentsMetadata": null,
"properties": null,
"variables": null
}
"@
Write-Host "Request Body :" $params
# Invoke the REST call and capture the results
$result = Invoke-RestMethod -Uri $uri -Method POST -Body $params -Headers $headers -ContentType "application/json" -Verbose -Debug
Write-Host "Result :" $result
# This call should only provide a single result
if ($result.count -eq 0)
{
Write-host "Unable to locate Release Definition Id $definitionId"
}
else
{
Write-host "Successfully triggered the VSTS release job !!!"
}
这篇关于当通过REST API排队Azure DevOps Pipeline版本时,是否可以更改"[user]的手动版本"?文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文