Understanding YAML Indentation in Azure DevOps Pipelines
When working with YAML pipelines in Azure DevOps , indentation isn’t just about readability—it directly defines how your pipeline is interpreted and executed. Let’s start with a correct and clean YAML structure . ✅ Correct Version variables: conn: test steps: - script: echo "Hello565 $(conn)" displayName: step1 - script: echo "Hello" displayName: step2 This structure ensures that: variables are defined at the root level steps is a list Each step contains properly aligned properties 🧠 How to Think About Spaces YAML uses spaces to represent hierarchy . Think of it like a tree structure: steps: # level 0 - script: ... # level 1 (2 spaces) displayName: ... # level 2 (aligned with script) Key Idea: Each level is indented using 2 spaces Elements at the same level must be perfectly aligned Misalignment changes how YAML is interpreted internally 🔁 Alternative: Multiline Script When your script conta...