Devops YAML-使用表达式设置内部版本名称 [英] Devops YAML - set build name using expression

查看:59
本文介绍了Devops YAML-使用表达式设置内部版本名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在yaml构建中,可以使用表达式设置构建名称吗?如果我可以将发布管道与实际的构建ID相匹配,那将是有利的.

In a yaml build, is it possible to set the build name using an expression; it would be advantageous if I could match the release pipeline with the actual build id.

示例:

trigger:  
- master

variables:  
    major: 2  
    minor: 3  
    offset: 2000  
    bid: $[$build.BuildID -as [int] + $offset]

name: "$(major).$(minor).$(bid)"

推荐答案

您可以使用

You can use the UpdateBuildNumber command to dynamically set the name as part of a bash or PowerShell script.

有关更多详细信息,请参见此博客文章,但是要点是这样的:

For more details you can see this blog post, but the gist of it is something like this:

name: 'Set dynamically below in a task'

variables:  
    major: 2  
    minor: 3  
    offset: 2000

steps:
- task: PowerShell@2
  displayName: Set the name of the build (i.e. the Build.BuildNumber)
  inputs:
    targetType: 'inline'
    script: |
      [int] $buildIdWithOffset = ([int] $(Build.BuildId)) + ([int] $(offset))
      [string] $buildName = "$(major).$(minor).$buildIdWithOffset"
      Write-Host "Setting the name of the build to '$buildName'."
      Write-Host "##vso[build.updatebuildnumber]$buildName"

这篇关于Devops YAML-使用表达式设置内部版本名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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