更新azure devops发布管道:版本为“ Deploy Plataform 3:1. *”的任务对于部署作业“在代理上运行”无效

时间:2019-05-22 16:35:49

标签: azure azure-functions azure-devops-rest-api

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

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

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

我想使用来自Azure DevOps Services REST API的update method添加一个新任务'Deploy plataform 3'。

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

我使用URL get发布版本: driver.get("https://careernavigator.naukri.com/sales-executive-retail-careers-in-mahindra-and-mahindra-financial-services-15731"); String webtable = driver.findElement(By.xpath("//body/div[@class='wrapper']/div[@class='leftwrap fl']/div[@id='f1']/div[@id='rph1']/*[1]")).getText(); System.out.println(webtable);

我在对象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

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

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

1 个答案:

答案 0 :(得分:0)

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

WorkflowTask的documentation未完成,我们只有:TaskId: string