You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Azure发布管道中获取关联构建管道的版本号?

获取关联构建管道的版本号

你需要使用Azure DevOps为关联资源管道提供的专属变量,而非发布管道自身的$(Build.BuildNumber)。

根据你定义的资源管道别名buildPipeline,对应的构建版本号变量为$(resources.pipeline.buildPipeline.buildNumber)。修改你的PowerShell任务如下:

- task: PowerShell@2
  displayName: Version output
  inputs:
    targetType: "inline"
    script: |                     
     Write-Host "关联构建管道的版本号是: $(resources.pipeline.buildPipeline.buildNumber)"

补充说明

除了buildNumber,还可以通过以下内置变量获取关联构建管道的其他信息:

  • $(resources.pipeline.buildPipeline.runId):构建管道的运行ID
  • $(resources.pipeline.buildPipeline.sourceBranch):构建对应的分支
  • $(resources.pipeline.buildPipeline.runUri):构建运行的页面链接

这些变量由Azure DevOps自动为关联的资源管道生成,无需额外配置即可直接使用。

内容的提问来源于stack exchange,提问作者pantonis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 08:18:35