【问题标题】:how to automate version of azure ARM template如何自动化 azure ARM 模板的版本
【发布时间】:2017-12-04 21:23:09
【问题描述】:

我正在 VSTS 中为 Azure ARM 模板构建 CI/CD 管道

当我在 VSTS 中开始构建时:

- ARM template is generated with a build script I wrote
- ARM template is deployed to Azure

我希望在每次启动构建时添加一个步骤来增加 ARM 模板的版本。

VSTS 是否有任何开箱即用的功能来为我增加此版本号?还是我必须编写一个脚本,从 arm 模板中读取当前版本,将其递增 1,然后将更改推送到 GIT?有没有办法优化这个过程?

【问题讨论】:

    标签: continuous-integration versioning azure-pipelines azure-resource-manager


    【解决方案1】:

    没有官方的扩展可以做到,你可以通过PowerShell脚本做到,你也可以自定义构建任务扩展来做并分享给其他人。 Add a build task

    更新版本的简单脚本:

    param(
    [string]$filepath
    )
    [object]$armObj=Get-Content $filepath|ConvertFrom-Json
    $vArray=$armObj.contentVersion.split(".")
    $vArray[-1]=[int]$vArray[-1]+1
    $armObj.contentVersion=$vArray -join '.'
    $armObj | ConvertTo-Json -Depth 10 |  % { [System.Text.RegularExpressions.Regex]::Unescape($_) } | set-content $filepath
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-01
      • 1970-01-01
      • 2022-11-03
      • 2017-03-23
      • 2018-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多