Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you debug Azure DevOps YAML file?

Tags:

azure-devops

There are 3 ways to write Azure DevOps builds, as I can see it:

  1. Add tasks using GUI for every little thing
  2. YAML
  3. A very few tasks, most of the work is delegated to Powershell. Only use tasks for things like Publish symbols or tests.

So far I am a fan of the last way because it allows me to debug most of my build logic locally. However, there are downsides:

  1. Does not communicate the build structure
  2. No detailed timeline

It is possible to address the latter through dedicated VSTS logging commands, but this seems tedious.

I am not considering the first option serious, because the build is not treated as code.

YAML option is very intriguing, but how do I debug it locally? So, I can debug various pieces when they call my powershell scripts, but is there a way to debug it really? Like running locally, I do not hope to place breakpoints inside the YAML, but being able to break inside the scripts (without ReadHost) would be terrific.

like image 274
mark Avatar asked Oct 25 '19 01:10

mark


People also ask

How do I debug my Azure DevOps pipeline?

Get logs to diagnose problems Start by looking at the logs in your completed build or release. You can view logs by navigating to the pipeline run summary and selecting the job and task. If a certain task is failing, check the logs for that task.

How do I debug in DevOps?

From Visual Studio, select Tools > Options > Debugging. Select Symbols from the list, and then select the + sign to add a new Azure DevOps symbol server location.


1 Answers

In earlier agent it supports locally testing YAML configuration without queuing a build against the server, but it's internal only and according to my test it's not available now. Please refer to YAML getting started - Run local (internal only, public preview soon) for details.

So, currently, we are unable to fully debug YAML locally. However Microsoft have added a new functionality to the Azure Pipelines extension for VSCode. Now, you will be able to create Azure Pipelines directly from VSCode without leaving the IDE.

Enter the Azure Pipelines extension for Visual Studio Code. Now, you can have syntax highlighting and IntelliSense that's aware of the Azure Pipelines YAML format. This means that you’ll be alerted in red “ink” if you write “tasks:” where you should have written “task:”. IntelliSense is also schema-aware. Wherever you are in the file, press Ctrl-Space (or Cmd-Space on macOS) to see what’s accepted at that point in the file.

You can reference below blogs to edit/debug the YAML file with VSCode:

  • How to edit a YAML Azure DevOps Pipeline
  • Using VS Code Extension for Azure Pipeline–Part1

In addition, there's also a suggestion ticket submitted about that : Ability to test YAML builds locally and the state is Under Review. You could also go and vote it up to achieve that in future release.

enter image description here

like image 147
Andy Li-MSFT Avatar answered Sep 18 '22 13:09

Andy Li-MSFT