Hosting » Azure » How do I set environment variables in Azure pipeline?

How do I set environment variables in Azure pipeline?

Last updated on December 26, 2022 @ 4:40 am

Azure Pipelines is a tool that helps manage your Azure cloud-based applications. It can be used to automate the deployment, running, monitoring, and management of your applications.

To use Azure Pipelines, you will need to set environment variables. This guide will show you how to do that.

Step 1

Open your Azure DevOps Dashboard then click Pipelines.1.11 Open your Azure Pipeline Dashbsord

Step 2

Click Create Pipeline under Pipeline Tab. 2.1 Create Pipeline

Step 3

Decide where your code’s source will be. I’ve decided to use GitHub for this tutorial.3. Where is your code.

Step 4

Select a repository.3.1 Select a repository.

Step 5

You will be prompted to approve and install Azure Pipelines, just click Approve & Install to proceed.3.2 You will be prompted to approve and install Azure Pipelines.

Step 6

The next prompt would be with Microsoft. Sign in to your Microsoft Account.3.3 Sign in to your Microsoft Account.

Step 7

Configure your pipeline. I’ve decided to Start with a minimal pipeline by choosing Starter Pipeline for this tutorial.3.4 Configure your pipeline.

Step 8

Review your Pipeline YAML and click Variables.3.5 Reveiw your Pipeline YAML and click Variables.

Step 9

Click New variable.3.6 Add New Variable.

Step 10

Create a new variable by assigning a Name and Value. Click OK when you are done.3.7 Create a new variable.

Step 11

You can add more variables if you want and if you’re all done hit Save.3.8 Hit Save.

Step 12

Click Save again to save the changes.3.9 Hit Save again to save the changes.

Step 13

Add commit message and optional info then hit Save.3.10 Add commit message and optional info..

Step 14

You can now test it by clicking Run pipeline.4. You can now run your pipeline

PRO TIP: If you are using Azure Pipeline to set environment variables, be aware that there is a potential for race conditions if multiple jobs are running in parallel. If one job tries to set an environment variable while another job is in the process of reading it, the results may be unpredictable.

Note that you can use environment variables in your code and in your Pipelines scripts. However, you can’t use environment variables in your pipeline definitions.

Kathy McFarland

Kathy McFarland

Devops woman in trade, tech explorer and problem navigator.