Azure DevOps pipelines use variables to store and manage data that can be used throughout the CI/CD process. These variables can hold values like configuration settings, environment-specific information, and secrets. Azure DevOps provides different types of variables, including predefined system variables and custom variables that you can define. Here's an overview of Azure DevOps pipeline variables:
System Variables:
These are predefined variables provided by Azure DevOps. They include information about the pipeline, build agent, and more. Some common system variables include:
- Build.BuildNumber: The build number or identifier.
- Build.SourceBranch: The source code branch being built.
- Build.Repository.Name: The name of the source code repository.
- Agent.Name: The name of the build agent.
Custom Variables:
You can define your own custom variables to store values specific to your pipeline. Custom variables can be defined at different levels:
- Pipeline Variables: Defined at the pipeline level, these variables are available to all stages and jobs within the pipeline.
- Stage Variables: Defined at the stage level, these variables are available to all jobs within a specific stage.
- Job Variables: Defined at the job level, these variables are specific to a particular job within a stage.
Secret Variables:
Secret variables are a special type of custom variable designed to store sensitive data like API keys, passwords, or connection strings. They are encrypted and not exposed in logs or build summary.
Variable Groups:
Azure DevOps also allows you to group variables together into Variable Groups. Variable Groups make it easier to manage and share variables across multiple pipelines or environments, helping you centralize configuration settings.
Remember to use secret variables for sensitive data and avoid hardcoding values in your pipeline scripts. Instead, use variables to make your pipelines more flexible and maintainable. These variables can be defined and managed in the Azure DevOps portal or defined directly in your YAML pipeline configuration, depending on your preference and requirements.
No comments:
Post a Comment