Ever wanted to dump all the VSTS variables during CI or CD pipeline in VSTS? Also want it to work in both Linux and Windows MS hosted agents? I know on windows machines, you can do write few lines in PowerShell to get the exact same thing. But this involves few lines of code and also does not work in Linux machines. In this blog post I will show you simple way to quickly dump all the VSTS variables with just one line of code. Yes! just one line of code.

The solution is to use the Bash step in your pipeline.

The benefit of this command is that, this also works in both Windows and Linux based hosted agents.

Okay, the first thing you need is a bash task. You add this to your build/release pipeline is by searching for Bash task.


Next step is to configure the task. Select Inline and in the script box, write the magic line.

printenv | sort

Notice I also pipe it and pass it to sort to sort the variables.


Once your build starts, it will look like below in the VSTS hosted windows agent


And on the hosted Ubuntu agent, it will look exactly the same.


Isn’t it great?

BTW, if for some reason you dislike bash task and only targeting Windows agents, there is alternate way of dumping all variables using Command Line task. Just add the task and in the script text box enter below command

cmd /k set

Thanks for reading!

About author
Utkarsh Shigihalli
Utkarsh Shigihalli
Utkarsh is passionate about software development and has experience in the areas of Azure, Azure DevOps, C# and TypeScript. Over the years he has worked as an architect, independent consultant and manager in many countries including India, United States, Netherlands and United Kingdom. He is a Microsoft MVP and has developed numerous extensions for Visual Studio, Visual Studio Code and Azure DevOps.
We Are
  • onlyutkarsh
    Utkarsh Shigihalli
    Microsoft MVP, Technologist & DevOps Coach

  • arora_tarun
    Tarun Arora
    Microsoft MVP, Author & DevOps Coach at Avanade

Do you like our posts? Subscribe to our newsletter!
Our Book