Seeing the output at any point in time is very important while automating a process; for that reason we usually set variables and display them during the build. In VSTS the public variables can be defined in the Variables tab or in the running process.
Knowing and seeing the value of Environment variable is part of the issue described above, and is, therefore, also very important. The following links provide the lists of Build Variables and Build definition source repositories.
Video You can see this video, if you would like to find more information about how to get started with Release Management and its advantages. See how to create a build definition using CI/CD Tools for VSTS Extensions (I will be using Package Extension and Publish Artifact tasks), and also using DevOps-VSTS-POC trigger in order to enable CI, all of that in order to be able to publish, share, install and query versions. You will see how to create release definition, choose an artifact and configure source for the artifact and default version. See how to create different environments or clone the existing one, in my case I am going to create QA, Preproduction and Production environment, each with one phrase and one task. See also how to configure Publish Extension task for each environment See an end-to-end continuous delivery pipeline using VSTS extension with Build and Release Management.
The process of setting and displaying a variable is described in more detail below.
First, I create Command Line task to write my name, so I can recognize that part very quickly.
Then I create the second Command Line to print out the value, remember the variable is $(var), but since we use that with echo, – we will use %var%.
Tip If you would like to learn more about using the Build Variables in VSTS and Release Management, – have a look at the following post: VSTS Build variables and Echo. The post describes how to see the output at any point of time, while automating a process, through setting variables and displaying them during the build.
The following image demonstrates how the values are displayed.
More InfoIf you would like to know more about Azure deployments, have a look at the post How to deploy to Azure using Team Services Release Management. The post describes how Azure deployments are made easy by using Visual Studio Team Services (VSTS) Release Management. You will see a step-by-step tutorial on how to configure and deploy to Azure in Release Management, and, moreover, how to configure an end-to-end pipeline for deploying applications on Azure.
How to send argument to PowerShell and read them during VSTS Build
The PowerShell script will contin write-host with arg number
In the PowerShell task, we send the arguments by putting each argument in double quotes with space separator
When we run the build, it will look like the following
Use Build variables and send them as arguments to PowerShell task which run PowerShell script
Using the previous example, we will set 2 variables, also I made the one of them secret as it hold the password as the following:
Now, I can use them as argument by sending each variable in double quotes with $(var) and space separator as the following:
When I run the build this will display the arguments variables as the following:
Access the VSTS Build variables without sending PowerShell arguments
I don’t have to send PowerShell arguments as I can access my variables that I set them in the VSTS build, the access here by calling them in the PowerShell script.
For example in our scenario, I set variable domain.username to access it within script, I need to transfer “.” to “_” so I have call it as $env:domain_username