Azure DevOps System Variables

Share

Azure DevOps System Variables

Azure DevOps provides a range of predefined system variables that you can use in your build and release pipelines. These variables offer information about the current pipeline run, environment, agent, and other system details. They are automatically set by Azure DevOps and are read-only. Here are some key system variables and their uses:

Common Azure DevOps System Variables

  1. Pipeline Variables:

    • System.DefinitionId: The ID of the build or release definition.
    • System.TeamProject: The name of the project.
    • System.TeamFoundationCollectionUri: The URL of the Azure DevOps organization.
    • Build.BuildId: The unique ID for the current build.
    • Build.BuildNumber: The build number/name as defined in the build definition.
    • Build.Repository.Name: The name of the repository.
  2. Agent Variables:

    • Agent.Id: The ID of the agent that is running the current job.
    • Agent.MachineName: The name of the machine on which the agent is running.
    • Agent.OS: The operating system of the build agent.
    • Agent.WorkFolder: The working directory for the agent.
  3. Job Variables:

    • System.JobId: The ID of the job.
    • System.PhaseDisplayName: The display name of the current phase.
  4. Artifact Variables:

    • Build.ArtifactStagingDirectory: The local path on the agent where any artifacts are copied to before being pushed to their destination.
  5. Source Control Variables:

    • Build.SourceBranch: The branch of the source code that is being built.
    • Build.SourceVersion: The commit ID (or changeset for TFVC) being built.

How to Use System Variables

  • System variables can be accessed in your build and release pipelines.
  • In YAML pipelines, you can use them as $(VariableName). For example, $(Build.BuildId).
  • In scripts, you can access them as environment variables. For example, in a PowerShell script, you could use $env:BUILD_BUILDID.

Best Practices

  • Read-Only: Remember that system variables are read-only and cannot be modified.
  • Debugging: Use system variables for debugging and diagnostic purposes. They can provide valuable information about the context of the pipeline run.
  • Dynamic Behavior: Some system variables can have different values based on the context of the pipeline (e.g., the branch being built).

Demo Day 1 Video:

 
You can find more information about DevOps in this DevOps Link

 

Conclusion:

Unogeeks is the No.1 IT Training Institute for DevOps Training. Anyone Disagree? Please drop in a comment

You can check out our other latest blogs on  DevOps here – DevOps Blogs

You can check out our Best In Class DevOps Training Details here – DevOps Training

💬 Follow & Connect with us:

———————————-

For Training inquiries:

Call/Whatsapp: +91 73960 33555

Mail us at: info@unogeeks.com

Our Website ➜ https://unogeeks.com

Follow us:

Instagram: https://www.instagram.com/unogeeks

Facebook:https://www.facebook.com/UnogeeksSoftwareTrainingInstitute

Twitter: https://twitter.com/unogeeks


Share

Leave a Reply

Your email address will not be published. Required fields are marked *