gpt4 book ai didi

azure - 更新azure devops发布管道: Tasks with versions 'Deploy Plataform 3:1.*' are not valid for deploy job 'Run on agent'

转载 作者:行者123 更新时间:2023-12-03 01:38:13 25 4
gpt4 key购买 nike

我正在使用 Azure DevOps Services REST API 5.0 来更新管道版本。

我有一个带有阶段 DEV 的版本,该版本在“在代理上运行”作业中有两个任务:

  • 部署平台 1
  • 部署平台 2

我想使用 update method 添加新任务“部署平台 3”来自 Azure DevOps 服务 REST API。

但是当我尝试更新时出现错误:
版本为“部署平台 3:1.*”的任务对于阶段 DEV 中的部署作业“在代理上运行”无效。

get使用 url 的发布定义:https://vsrm.dev.azure.com/organizationname/projectname/_apis/release/definitions/5?api-version=5.0

我在对象 environments[0].deployPhases[0].workflowTasks 中添加了一个新任务。

Workflowtasks 对象与我的新任务:

"workflowTasks": [
{
"environment": {},
"taskId": "501dd25d-1785-43e4-b4e5-a5c78ccc0573",
"version": "1.*",
"name": "Deploy Plataform 1",
"refName": "",
"enabled": true,
"alwaysRun": false,
"continueOnError": false,
"timeoutInMinutes": 0,
"definitionType": null,
"overrideInputs": {},
"condition": "succeeded()",
"inputs": {
"azureSubscription": "3ca9b800-e82b-4678-8483-xxxxx",
"appType": "$(Parameters.AppType)",
"appName": "app func name 1",
"deployToSlotOrASE": "false",
"resourceGroupName": "",
"slotName": "production",
"package": "$(System.DefaultWorkingDirectory)/**/*.zip",
"runtimeStack": "",
"startUpCommand": "",
"customWebConfig": "",
"appSettings": "",
"configurationStrings": "",
"deploymentMethod": "auto"
}
},
{ ...
},
{
"environment": {},
"taskId": "502dd25d-1785-43e4-b4e5-a5c78ccc0573",
"version": "1.*",
"name": "Deploy Plataform 3",
"refName": "",
"enabled": true,
"alwaysRun": false,
"continueOnError": false,
"timeoutInMinutes": 0,
"definitionType": "task",
"overrideInputs": {},
"condition": "succeeded()",
"inputs": {
"azureSubscription": "3ca9b844-e92b-4678-8483-xxxx",
"appType": "functionApp",
"appName": "func app name",
"deployToSlotOrASE": "false",
"resourceGroupName": "",
"slotName": "production",
"package": "$(System.DefaultWorkingDirectory)/**/*.zip",
"runtimeStack": "",
"startUpCommand": "",
"customWebConfig": "",
"appSettings": "",
"configurationStrings": "",
"deploymentMethod": "auto"
}
}
]

放置网址:https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions?api-version=5.0

错误:

Invoke-RestMethod : {"$id":"1","innerException":null,"message":"Tasks with versions 'Deploy Plataform 3:1.*' are not valid for deploy job 'Run on agent' in stage DEV.
","typeName":"Microsoft.VisualStudio.Services.ReleaseManagement.Data.Exceptions.InvalidRequestException, Microsoft.VisualStudio.Services.ReleaseManagement2.Data","typeKey":"InvalidRequestException","errorCode":0,"eventId":3000}
Au caractère C:\Projects\TransportConfiguration\AutomationTasks\Build Definitions Supporting Scripts\Update-Release-Stage.ps1:49 : 9
+ Invoke-RestMethod -Uri $uri -Headers ($Header) -Method PUT -B ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation : (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

放置方法:

function Invoke-WebRequestPut ([PSCustomObject] $releaseDefinition) {    

$uri = "https://vsrm.dev.azure.com/organizationname/projectname/_apis/release/definitions?api-version=5.0"

$Auth = '{0}:{1}' -f $UserName, $PersonalToken
$Auth = [System.Text.Encoding]::UTF8.GetBytes($Auth)
$Auth = [System.Convert]::ToBase64String($Auth)
$Header = @{Authorization = ("Basic {0}" -f $Auth)}

$body = $releaseDefinition | ConvertTo-Json -Depth 30

$body2 = [System.Text.Encoding]::UTF8.GetBytes($body)


Invoke-RestMethod -Uri $uri -Headers ($Header) -Method PUT -Body $body2 -ContentType "application/json"
}

使用此 put 方法,我可以成功修改现有任务名称(部署平台 1 => 部署平台 X)。但无法添加新任务。

这是一个错误,或者我遗漏了一些东西。

最佳答案

我发现了问题。
我添加的新 WorkflowTask 有一个我试图生成的字段 taskId。但这个 taskId 字段对应于我想要使用的 azure pipeline 任务 类型。就我而言,我需要设置azure function app任务ID,501dd25d-1785-43e4-b4e5-a5c78ccc0573

documentation对于 WorkflowTask 并不完整,我们只有: TaskId: string

关于azure - 更新azure devops发布管道: Tasks with versions 'Deploy Plataform 3:1.*' are not valid for deploy job 'Run on agent' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56261427/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com