How do you debug Azure DevOps YAML file?

Viewed 9276

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.

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:

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

Related