【发布时间】:2019-07-15 08:54:56
【问题描述】:
我需要在发布管道中使用Build.Repository.Uri。 (将其传递给 PowerShell 脚本)
在构建管道中:
Write-Host $(Build.Repository.Uri)
> 2019-07-15T08:30:51.8695425Z http://138.202.18.216:8070/Samples/Framework%20A/_git/Framework%20A
在发布管道中:
Write-Host $(Build.Repository.Uri)
> The name Build.Repository.Uri was not recognized as the name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if the path is correct (if included), and try again.
为什么会出现这种不一致?
我也尝试Write-Host $(env:BUILD_REPOSITORY_URI),因为:How to read directory path of the Artifact in Release pipeline in Azure DevOps?(我也不明白.to_背后的逻辑)
有没有办法在发布管道中获取Build.Repository.Uri?
编辑:解决方案
"$env:SYSTEM_TASKDEFINITIONSURI$env:BUILD_PROJECTNAME/_git/$env:BUILD_REPOSITORY_NAME" -> http://136.202.18.216:8070/Samples/Framework A/_git/Framework A
如果您将system.debug 变量设置为true,您可以在构建后在Job Initialize (Auftrag initialisieren) 报告中找到所有预定义变量。
如果您的项目或存储库名称包含空格,请确保在脚本中将它们替换为 %20:
$Uri = $Uri.Replace(" ", "%20")
【问题讨论】:
标签: azure-devops azure-pipelines