Azure Pipeline Part 13 – Logging

Azure Pipeline Part 13 – Logging

Azure Pipeline Part 13 – Logging

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

Today we are going to discuss how to log errors and other useful information in Azure Pipeline using logging commands.

Azure Pipeline Part 13 – Logging

Prerequisites:

Setup:

Azure Pipeline – Logging Commands:

Logging commands are how tasks and scripts communicate with the agent. They cover actions like creating new variables, marking a step as failed, and uploading artifacts. Logging commands are useful when you are troubleshooting a pipeline.

Azure Pipeline – Logging Commands Syntax:

Azure Pipeline – Logging – Formatting Commands:

You can log an error or other types of messages in your Azure Pipeline using formatting commands. This messaged will be visible to the Azure Pipeline UI.

Azure Pipeline – Logging – Formatting Commands Examples:

If you check the Azure Pipeline UI, it will show the logged messages as shown below

Azure Pipeline Part 13 – Logging

Azure Pipeline – Logging – Task Commands:

Task commands can be used to define the task status, log an error or warning for task execution, show task completion percentage, set task variables, upload a file or update an endpoint at runtime. Below are all supported task commands available in Azure Pipeline.

  • LogIssue: Log an error or warning message in the timeline record of the current task.
  • SetProgress: Set progress and current operation for the current task.
  • Complete: Finish the timeline record for the current task, set task result and current operation. When result not provided, set result to succeeded.
  • SetVariable: Sets a variable in the variable service of taskcontext. The first task can set a variable, and following tasks are able to use the variable. The variable is exposed to the following tasks as an environment variable.
  • SetEndpoint: Set a service connection field with given value. Value updated will be retained in the endpoint for the subsequent tasks that execute within the same job.
  • AddAttachment: Upload and attach attachment to current timeline record. These files are not available for download with logs. These can only be referred to by extensions using the type or name values.
  • UploadSummary: Upload and attach summary markdown to current timeline record. This summary shall be added to the build/release summary and not available for download with logs.
  • UploadFile: Upload user interested file as additional log information to the current timeline record. The file shall be available for download along with task logs.

Azure Pipeline – Logging – Task Commands Examples:

Note: Apart from task commands, Azure pipeline also have artifact, build and release commands. You can get more details on this link.

Clean up:

Hope you have enjoyed this article. To know more about Azure DevOps, please refer below official documentation

https://docs.microsoft.com/en-us/azure/devops/?view=azure-devops

Leave a Reply

Close Menu