我有一个要求,以获得版本的内部版本神器的名字吗?我没有看到一个预定义的释放变量可以得到这个。有没有一种方法来获取呢?
如果你的意思是你想获得它在Artifact Name
任务定义在构建过程中(默认情况下它是Publish Build Artifacts
)的Drop
,那么你可以运行下面的PowerShell脚本调用REST API检索值,并设定记录命令的变量。在此之后,你可以在后续任务变量...
Allow scripts to access the OAuth token
Agent Phase
$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...
这是部分普通神器变量和初级假象变量下well-documented。
主要的产品名称是Build.DefinitionName
。