The Azure Pipelines and Github Workflows YAML code is jumbled (lost indentation)

Olivia WIlcox 0 Reputation points
2024-12-24T23:09:30.01+00:00

On page https://zcusa.951200.xyz/en-us/training/modules/implement-pipeline-strategy/6-implement-code-coverage-show-pipeline the code samples aren't formatted properly. They appear as one line. They are supposed to be YAML but the spacing is off. So, they won't work without having to know where to put newlines and spaces to properly format the YAML files.

This question is related to the following Learning Module

Azure Training
Azure Training
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.Training: Instruction to develop new skills.
1,877 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Pradeep M 4,560 Reputation points Microsoft Vendor
    2024-12-26T06:06:15.23+00:00

    Hi Olivia WIlcox,

    Thank you for reaching out to Microsoft Q & A forum. 

    It seems the YAML code samples on the page may have lost their indentation and proper formatting, which is essential for YAML files to function correctly. This could be due to display or formatting errors on the page itself. To resolve this, you can manually reformat the code by following YAML's indentation rules. YAML files use spaces (not tabs) for indentation, with two spaces per level of nesting. 

    Steps to Fix YAML Formatting: 

    1.Understand YAML Basics: 

    Use spaces, not tabs, for indentation. 

    Indent by two spaces per level for nesting. 

    Format key-value pairs as key: value. 

    2.Organize the Code: 

    Start with top-level keys with no indentation. 

    For nested blocks, indent them by two spaces. 

    Use text editors for auto formatting: 

    1.Visual Studio Code (Recommended): 

    Open your YAML file, install the YAML extension (e.g., "YAML" by Red Hat), and use Shift + Alt + F to auto-format. 

    2.Notepad++: 

    Install the YAML plugin and use the "Auto Indent" feature under the "Plugins" menu. 

    3.PyCharm or IntelliJ: 

    Open the YAML file and use Code > Reformat Code (or the shortcut Ctrl + Alt + L) to auto-format. 

    Once you've reformatted the code, I recommend validating it using an online tool like YAML Lint to ensure its properly structured. 

    Please feel free to contact us if you have any additional questions.     

    If you have found the answer provided to be helpful, please click on the "Accept answer/Upvote" button so that it is useful for other members in the Microsoft Q&A community

     


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.