Create Global Variable and Variable Groups to use in Azure Devops Pipeline

Variable Inside Specific Pipeline

  1. Go to Pipeline at the sidebar > choose pipeline

  2. At the top side of the screen, click Edit.

  3. Click on the Variable button located at the top right of the screen.

variables

  1. Click on the cross button to add new variable. Fill in the name and value.

Note:

To reference a variable in YAML, prefix it with a dollar sign and enclose it in parentheses. For example: $(variable-name) To use a variable in a script, use environment variable syntax. Replace . and space with _, capitalize the letters, and then use your platform's syntax for referencing an environment variable. Examples: Batch script: %VARIABLE-NAME% PowerShell script: ${env:VARIABLE-NAME} Bash script: $(VARIABLE-NAME)

  1. All the list of variables that you customized will be listed on the side bar

variable-global

  1. This is now avaiable for use in the pipeline file.

Create Azure Variable Group that is Accessble for All Pipelines

  1. Go to Library at the sidebar

  2. Click on the

    • Variable Group
    selection

  3. Fill in the Variable Group name, description, toggle link secrets, and Add variables

variable-global

Here is the sample yml content where I placed the variable group and individual variable

- script: |
    doppler run -p $(projectVariable) -c <environmentVariable> --command "node generateEnv.cjs"
  displayName: 'Generate Environments'
  env:
    DOPPLER_TOKEN: $(TOKEN_DEV)