Reputation: 2392
I need to use Build.Repository.Uri
in a release pipeline. (to pass it to a PowerShell script)
In a buildpipeline:
Write-Host $(Build.Repository.Uri)
> 2019-07-15T08:30:51.8695425Z http://138.202.18.216:8070/Samples/Framework%20A/_git/Framework%20A
In a releasepipeline:
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.
Why that inconsistency?
I also try Write-Host $(env:BUILD_REPOSITORY_URI)
because of that: How to read directory path of the Artifact in Release pipeline in Azure DevOps? (I also don't understand the logic behind . to _)
Is there a way to get Build.Repository.Uri
in a releasepipeline?
EDIT: Solution
"$env:SYSTEM_TASKDEFINITIONSURI$env:BUILD_PROJECTNAME/_git/$env:BUILD_REPOSITORY_NAME" -> http://136.202.18.216:8070/Samples/Framework A/_git/Framework A
If you set system.debug
variable to true
, you can find all predefined variables inside of the Job Initialize
(Auftrag initialisieren) Report after a build.
If your project or repository name contains spaces, make sure that you replace them in your script with %20
:
$Uri = $Uri.Replace(" ", "%20")
Upvotes: 1
Views: 3250
Reputation: 707
The variable Build.Repository.Uri is agent-scoped. It can be used as an environment variable in a script and as a parameter in a build task. When you add variable System.Debug
with value true in the pipeline, the init job will log all the available environment variables, which includes the REPOSITORY_URI.
You can try with following variables:
Write-Host $env:BUILD_REPOSITORY_URI
Or
Write-Host $env:RELEASE_ARTIFACTS_{alias}_REPOSITORY_URI
Please note that the {alias} is the uppercase of the Artifact source alias.
Upvotes: 1
Reputation: 697
To access the Build URI in the Release Pipeline you need to use the release variable:
Release.Artifacts.{alias}.BuildURI
{alias}
is the the alias of the artifact source you have in the release
If you accessing variables within PowerShell scripts you need to replace any dots with underscores i.e. $env:RELEASE_ARTIFACTS_{alias}_BUILDURI
Upvotes: 1