PrintOut - Pre-defined Variable Values

 You can print out the values of predefined variables in an Azure DevOps pipeline by using a script or a specific task. Here, I'll provide an example using a script task to print out the values of predefined variables in your pipeline YAML:

pool: vmImage: 'windows-latest' steps: - script: | echo "Build ID: $(Build.BuildId)" echo "Build Number: $(Build.BuildNumber)" echo "Source Branch: $(Build.SourceBranch)" echo "Repository Name: $(Build.Repository.Name)" echo "Source Version: $(Build.SourceVersion)" echo "Build Definition Name: $(Build.DefinitionName)" echo "Agent Name: $(Agent.Name)" echo "Agent OS: $(Agent.OS)" echo "Agent Job Name: $(Agent.JobName)" echo "Default Working Directory: $(System.DefaultWorkingDirectory)" displayName: 'Print Predefined Variables'

In this example:

  • We use the script task to execute a series of echo commands.
  • Inside the echo commands, we use the $(VariableName) syntax to reference and print the values of various predefined variables, such as Build.BuildId, Build.BuildNumber, Agent.Name, and others.
  • We also print out the values of System.DefaultWorkingDirectory to demonstrate accessing a predefined pipeline variable.

When you run this pipeline, it will execute the script task, and you'll see the values of the predefined variables printed in the pipeline logs. You can customize the script to include any predefined variables you want to inspect.

Remember to adjust the pool and agent configuration in the YAML to match your specific pipeline requirements, such as the operating system and image you're using.


Comments

Popular posts from this blog

Azure : Display the values of IN-Built Variables