Azure DevOps – Tips and Tricks – 23 – How to view the secret variables of a Variable Group

In this article, we are going to learn about a technique using which you can view the value of the secret variable created inside a Variable Group of Azure DevOps.

Advertisements

Introduction

Azure DevOps supports us to store secrets within Azure DevOps – Var Groups which could be used with the Pipelines. These secret variables couldn’t be viewed by us manually from the portal. Sometimes, we may want to view the password to perform some administrative activity.

In this article, we are going to learn how to create a pipeline that publishes the secret variable created in the Azure DevOps Variable Group.

Advertisements

Variable Groups – Secret variable

Let’s create a Secret variable in a Variable Group as shown below and make sure that you set it as a secret by locking it (#3 below).

1.Azure DevOps – Tips and Tricks – How to view the secret variables of a Variable Group – Create Secret

Once you mark it a secret, save the Var Group, no one including you will be able to view the secret. Let’s now understand how to view the secret with the help of Azure DevOps – Pipelines.

Advertisements

Azure Pipelines – View Secrets

Let’s create a simple Pipeline which has the below tasks in it.

  1. PowerShell task which outputs a text (along with secret) into a file names DisplaySecret.Txt
  2. Publish the DisplaySecret.txt into Azure Pipeline artifacts.

Let’s add the below script to the Azure DevOps – YAML Pipeline

variables:
- group: Tips
steps:
- powershell: |
    "the value: $(Secret)" | Out-File -FilePath  $(Build.ArtifactStagingDirectory)\DisplaySecret.txt
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'
Advertisements

Let’s now run the Pipeline which publish an artifact as shown below.

2.Azure DevOps – Tips and Tricks – How to view the secret variables of a Variable Group – View Artifact

Now, click on the DisplaySecret.txt file to download the file. Once you download it, view that in a Notepad which should like this.

3.Azure DevOps – Tips and Tricks – How to view the secret variables of a Variable Group – View Secret

That how you can view the secrets.

Advertisements

Summary

In this article, we have learnt how to view the secret value of a secret variable created within the Variable Group.

Do you like this article? If you want to get more updates about these kind of articles, you can join my Learning Groups

WhatsApp

Telegram

Advertisements
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s