如何在Devops / VSTS中自动启动先前成功发布的版本 [英] How to start previous successful release automatically in Devops/VSTS

查看:78
本文介绍了如何在Devops / VSTS中自动启动先前成功发布的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果当前版本失败,以及如何自动运行先前成功的版本?

If the current release has failed and how to run the previous successful release automatically?

Ex:如果A(当前发行版)失败,则自动触发B(先前成功发行版)发行。从另一个版本定义触发。

Ex: If A(Current release) has failed then automatically trigger B(Previous success release) release. Trigger from another release definition.

推荐答案

使用powershell调用api不需要那么复杂。我们内置的功能可以满足您的要求。由于发布管道包含一个或多个阶段,因此重新部署发布管道可以视为重新运行阶段。

No need to be so complicated to use powershell to call api. We have built-in feature can achieve your requirement. Since release pipeline consists of one or more stages,re-deploy release pipeline can be considered as re-running stages.

因此,请首先打开发布管道定义。然后导航到阶段的部署后条件 =>启用自动重新部署触发器 =>选择事件动作

So open the release pipeline definition first. Then navigate to Post-deployment conditions of the stage => Enable Auto-redeploy trigger => Select the Event and the action:

查看实际执行结果:

这是Azure Devops的优势,因此您不必担心在Prod部署期间是否会出问题,因为该工具将自动通过其自身自动撤消上一次成功的部署。

This is the advantage of the Azure Devops so that you don't need to worry if some thing goes wrong during the Prod deployments as the tool will automatically reverse the last successful deployment by its own.

已更新:

$connectionToken="{PAT}" 

$url="https://vsrm.dev.azure.com/{org}/{project}/_apis/release/releases?api-version=6.0"

$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)"))
    
$Body=@"
{
  "definitionId": {specific release definition id},
  "description": "Creating release from powershell",
  "artifacts": [
    {
      "alias": "{artifact name}",
      "instanceReference": {
        "id": "{buildid}",
        "name": null
      }
    }
  ],
  "isDraft": false,
  "reason": "none",
  "manualEnvironments": null
}
"@
Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Post -Body $Body -ContentType application/json

这篇关于如何在Devops / VSTS中自动启动先前成功发布的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆