在Octopus Deploy中,当主要或次要版本第一次部署到环境时,如何要求批准?

bwalk2895

想象您有五个环境,开发,测试,UAT,阶段和生产。

对于这些环境,您具有以下生命周期:-冲刺:开发->测试-测试到产品:测试-> UAT->阶段->产品-UAT到产品:UAT->阶段->产品-修补程序:阶段->产品

发行版本看起来像2020.1.3。剪切新版本时,它将更新版本号中的主要(2020)或次要(1)。例如2020.1.3转到2020.2.1或2021.1.1。错误修复或次要发行版将更新最后一个数字(3)。

令人担心的是,是否在错误的时间或意外地将一个版本部署到了Test,UAT或Stage,这会停止我们的测试人员。例如,质量检查正在进行Test中2020.1.3版本的测试。开发人员不小心将2020.2推送到Test。其中包括未预期的新代码质量检查。质量检查处于测试2020.1.x的过程中,他们只希望查看2020.1.x的发行版。

我们不想在我们的频道中使用版本规则每次剪切新版本时,都必须更新版本规则。

在将主要版本或次要版本第一次部署到环境中时,是否可能需要批准?

bwalk2895

是的,那是可能的。为此,我们将使用输出变量运行条件

首先,该过程的开始增加了两个新步骤。 部署过程中的批准步骤

这两个步骤都将跳过开发和生产,因为它们不受此问题的影响。每次主要/次要版本更改都必须批准部署才能进行开发,这确实会很快淘汰。并且所有生产版本至少必须首先进行登台。

第一步运行此PowerShell脚本。它将将此特定环境的先前发行版号与当前发行版号进行比较。如果主要版本或次要版本不同,它将输出变量“ RequiresApproval”设置为true。

$releaseNumber = $OctopusParameters["Octopus.Release.Number"]
$releaseNumberArray = $releaseNumber.Split('.')

$lastVersion = $OctopusParameters["Octopus.Release.PreviousForEnvironment.Number"]
$lastVersionArray = $lastVersion.Split('.')

Write-Highlight "The previous version deployed to this environment was $lastVersion"

$requiresApproval = $false
if ($lastVersionArray[0] -ne $releaseNumberArray[0])
{
    Write-Highlight "The previous major version $($lastVersionArray[0]) in $lastVersion is different than the one being deployed $($releaseNumberArray[0]) in $releaseNumber, this requires someone to approve"
    $requiresApproval = $true
}
elseif ($lastVersionArray[1] -ne $releaseNumberArray[1])
{
    Write-Highlight "The previous minor version $($lastVersionArray[1]) in $lastVersion is different than the one being deployed $($releaseNumberArray[1]) in $releaseNumber, this requires someone to approve"
    $requiresApproval = $true
}
else
{
    Write-Highlight "The previous version's major and minor versions are the same, skipping approval"
}

Set-OctopusVariable -name "RequiresApproval" -value $requiresApproval

输出变量有些冗长,使用起来很棘手。为了简化操作,创建一个项目变量来引用它。输出变量作为项目变量

在手动干预步骤中,将运行条件设置为该项目变量。 运行条件下的手动干预

现在该进行测试了。UAT当前有,2020.1.2而Test有2020.2.32020.2.4部署到测试时,不应显示手动干预。当前部署版本

成功,将跳过手动干预。 可变运行条件会在部署期间跳过步骤

UAT目前有2020.1.22020.2.4具有新的次要版本,部署到UAT将提示用户进行手动干预。
运行条件迫使手动干预

此YouTube视频演示了这一操作。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在Octopus Deploy中备份/还原单个环境

Octopus Deploy与VSTS发布工具

使用 Octopus Deploy in a Package 部署 ARM 模板

在创建新版本之前,Octopus Deploy使用部署快照。

Octopus 部署流程:步骤之间共享数据

Octopus 从库中部署变量替换

安装IIS作为Octopus Deploy中的一个步骤

Octopus Deploy部署未转换的配置文件

TeamCity Octopus Deploy创建版本无法读取API密钥

Octopus 在升级到生产之前部署检查包

从构建脚本将包推送到 Octopus Deploy 时出错

在开发环境中通过Octopus gem进行Rails Postgresql复制

Continua with Octopus 部署“RessourceNotFound”并进行重大更改

Octopus 部署 JSON 配置变量功能不起作用

Octo 因 json 错误推送失败(Octopus Deploy)

使用SQL脚本访问Octopus Deploy的系统变量

Octopus Deploy:操作返回了无效的状态代码“冲突”

Docker和Octopus Deploy有什么区别

在TeamCity构建期间将nuget包发布到Octopus

什么是Azure Devops中的Octopus程序包库

将生产环境数据库复制到使用Octopus进行部署之前的登台

使用octopus deploy部署asp.net站点时更改IIS文化

在使用Team City和Octopus Deploy时设置dotnet核心项目的版本?

如何告诉Octopus Deploy等待同一台计算机上的另一部署完成?

如何通过Octopus部署在IIS中创建嵌套的虚拟目录?

如何在 Octopus Deploy 中从侦听触手切换到轮询触手?

Octopus Deploy-变量替换部署目标计算机名称

在Octopus中,是否可以将文件上传到Octopus,然后将其复制到目标计算机中的文件位置?

通过Octopus和TeamCity将数据库包部署到SQL Server