Forum Discussion
Harmanvir
Jan 04, 2024Copper Contributor
Printing azure repo name in the azure pipeline yaml file
I want to get the name of the azure repo in the azure pipeline while being executed. I am using templetes in the pipeline code and my repo always changes. I tried using Build.Repository.Name but it d...
Kidd_Ip
May 30, 2025MVP
You may try the following as an alternative:
- Use System.PullRequest.SourceRepositoryUri (if using PRs)
If your pipeline is triggered by a pull request, you can extract the repository name from the source repository URI:
- script: echo $(System.PullRequest.SourceRepositoryUri)
displayName: "Print Repo Name from PR Source"
- Extract from Build.Repository.Uri
Try using the repository URI and parse out the repo name from it:
- script: echo $(Build.Repository.Uri)
displayName: "Print Repo URI"
- Use Build.SourceBranchName (if working with branches)
If your repo structure follows a naming convention tied to branches, you might be able to extract it dynamically:
- script: echo $(Build.SourceBranchName)
displayName: "Print Source Branch Name"