Azure DevOps Variables Predefined

Share

Azure DevOps Variables Predefined

Azure DevOps provides a set of predefined variables that are automatically set during the build and release pipeline processes. These variables give you access to data about the pipeline, the environment it is running in, and the context of the specific run. Predefined variables can be used without needing any additional configuration, making them highly useful for various automation tasks in your pipelines.

Key Categories of Predefined Variables in Azure DevOps

  1. Agent Variables: Provide information about the agent running the build or release. Examples include Agent.JobStatus, Agent.MachineName, Agent.OS, and Agent.Version.

  2. Build Variables: Relate to the build instance. Examples include Build.BuildId, Build.BuildNumber, Build.DefinitionName, Build.Repository.Name, and Build.SourceBranch.

  3. Release Variables: Specific to release pipelines. Examples include Release.ReleaseId, Release.ReleaseName, Release.EnvironmentName, and Release.DefinitionName.

  4. System Variables: Provide information about the system or environment where the pipeline is running. Examples include System.TeamProject, System.DefaultWorkingDirectory, and System.JobId.

  5. Pipeline Variables: General information about the pipeline. Examples include Pipeline.Workspace.

Using Predefined Variables

  • In YAML Pipelines: You can use these variables directly in your YAML file. For example, $(Build.BuildId) will be replaced by the build ID during the pipeline run.

  • In Classic Pipelines: They are available as environment variables and can be used in scripts or as parameters to tasks.

Common Use Cases

  1. Path Management: Using variables like System.DefaultWorkingDirectory to refer to the working directory in scripts.

  2. Dynamic Naming: Utilizing Build.BuildNumber for dynamically setting build artifact names.

  3. Conditional Execution: Using Agent.OS to run specific tasks for different operating systems.

  4. Accessing Repo Details: Using Build.Repository.Name to get the name of the repository where the build was triggered.

  5. Environment-Specific Tasks: Using release variables to execute tasks specific to an environment during a release pipeline.

Customizing Variables

  • You can also define your own variables in the pipeline, which can be set manually or through scripts, and used alongside these predefined variables.

Limitations and Security

  • Some variables are read-only and cannot be modified.
  • Be cautious with sensitive data. For sensitive or secret values, use secure variables or variable groups, which are masked in the logs.

Predefined variables in Azure DevOps are a powerful feature, providing essential context and data to your CI/CD processes, enabling more dynamic and adaptable pipeline configurations.

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 *