如何将内部版本号添加到Azure DevOps中的构建管道工件的名称中?

问题描述 投票:0回答:1

我正在Azure DevOps中构建一个.NET应用程序,使用GitVersion通过Cake脚本设置其版本,然后构建它。它似乎从GitVersion中创建的此值获取Build编号。我希望信息版本号填充我名字的一部分。我正在使用设计器,但为了易于使用,这里是发布工件步骤的YAML文件:

#Your build pipeline references the ‘deployment.PPILDeployDirectory’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
#Your build pipeline references the ‘deployment.integration.environment’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971

steps:
- task: PublishBuildArtifacts@1
  displayName: 'Publish Integration Artifact copy'
  inputs:
    PathtoPublish: '$(deployment.PPILDeployDirectory)'
    ArtifactName: '$(deployment.integration.environment)_integration_drop'

如何使用信息构建号(包括分支和构建信息)后缀ArtifactName?我需要抓取的变量是什么?是否还有其他与构建号相关的变量我应该注意哪些?

build azure-devops azure-artifacts
1个回答
2
投票

如何使用信息构建号(包括分支和构建信息)后缀ArtifactName?

您可以使用变量$(Build.BuildNumber)$(Build.SourceBranchName)作为ArtifactName的后缀,例如:

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: dist'
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'Test_$(Build.BuildNumber)_$(Build.SourceBranchName)'

构建之后,我们可以在摘要选项卡下看到日志,构建号是20190425.7,源分支是master

enter image description here

可用变量列表位于:

https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml#predefined-variables

希望这可以帮助。

© www.soinside.com 2019 - 2024. All rights reserved.