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

时间:2019-04-24 21:05:58

标签: build azure-devops azure-artifacts

我正在Azure Azure中构建.NET应用程序,并通过Cake脚本使用GitVersion设置其版本,然后对其进行构建。它似乎是从GitVersion中创建的此值获取内部版本号的。我希望信息性内部编号填充我的姓名的一部分。我正在使用设计器,但是为了易于使用,这是发布工件步骤的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后缀信息性的内部版本号(包括分支和内部版本信息)?我需要掌握什么变量?还有其他我应该注意的与内部版本号相关的变量吗?

1 个答案:

答案 0 :(得分: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

希望这会有所帮助。