Posts

Showing posts from April, 2026

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...

Understanding Spaces and Indentation in Azure DevOps YAML Pipelines

  When working with Azure DevOps YAML pipelines , one of the most important concepts to understand is indentation . Unlike programming languages that use braces ( {} ) or brackets ( [] ) to define structure, YAML relies entirely on spaces to represent hierarchy. Even a small indentation mistake can completely change how Azure DevOps interprets your pipeline. Why Indentation Matters Azure DevOps uses indentation to determine: Parent-child relationships between pipeline sections Which properties belong to an object Which items belong to a list/collection In simple terms: Indentation defines structure in YAML Basic Rule Use consistent spaces to nest child elements under parent elements. Recommended standard: Use 2 spaces per indentation level Never use tabs Correct Indentation Example pool: vmImage: ubuntu-latest What This Means pool is the parent object vmImage is a property inside pool Equivalent JSON: { "pool": { "vmImage": "ubuntu-latest" } ...