Saturday, January 28, 2023

The New Pre-defined System Variable in Azure DevOps Build Pipeline

There could be requirement to get Azure DevOps build definition location when developing scripts to use with Azure DevOps. In such script, you can hardcode build definition location or use recently introduced pre-defined system variable, Build.DefinitionFolderPath in Azure DevOps.


Pre requirement: Azure DevOps build definition

The build definition we use for this blog post is under Demo Build Pipeline.

 

Let's try to use pre-defined build variable inside the build to get build definition path.

Add following PowerShell task to build pipeline to get build definition location.

taskPowerShell@2
  inputs:
    targetType'inline'
    script: |
      # Write your PowerShell commands here.
      
      Write-Host " This is build definition folder path"
      Write-Host $(Build.DefinitionFolderPath)

You would be able to get build definition location using the pre-defined variable as below.




No comments:

Post a Comment