是否有可能得到神器名称的发布?

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

我有一个要求,以获得版本的内部版本神器的名字吗?我没有看到一个预定义的释放变量可以得到这个。有没有一种方法来获取呢?

azure azure-devops
2个回答
1
投票

如果你的意思是你想获得它在Artifact Name任务定义在构建过程中(默认情况下它是Publish Build Artifacts)的Drop,那么你可以运行下面的PowerShell脚本调用REST API检索值,并设定记录命令的变量。在此之后,你可以在后续任务变量...

  1. 启用Allow scripts to access the OAuth token Agent Phase
  2. 添加任务的PowerShell脚本下方运行 $url = "$($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)$env:SYSTEM_TEAMPROJECTID/_apis/build/builds/$env:BUILD_BUILDID/artifacts?api-version=4.1" Write-Host "URL: $url" $pipeline = Invoke-RestMethod -Uri $url -Headers @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" } Write-Host "artifactName:" ($artifactName = $Pipeline.value.name) #Set Variable $artifactName Write-Host "##vso[task.setvariable variable=artifactName]$artifactName" #Then you can use the variable $artifactName in the subsequent tasks...

enter image description here


0
投票

这是部分普通神器变量和初级假象变量下well-documented

主要的产品名称是Build.DefinitionName

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