Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Azure Pipelines overview
📖 Scenario: You are working in a software development team that wants to automate building and testing their code every time they make changes. Your team uses Azure DevOps, and you want to create a simple pipeline to help with this automation.
🎯 Goal: Create a basic Azure Pipeline YAML file that defines a pipeline to build and test a simple application automatically.
📋 What You'll Learn
Create a YAML file named azure-pipelines.yml.
Define a pipeline that triggers on any change to the main branch.
Add a job with a single step that runs a script to print Hello, Azure Pipelines!.
Use the ubuntu-latest virtual machine image for the job.
💡 Why This Matters
🌍 Real World
Automating builds and tests helps teams deliver software faster and with fewer errors by running tasks automatically on code changes.
💼 Career
Understanding Azure Pipelines is essential for roles in DevOps, cloud engineering, and software development to implement continuous integration and continuous delivery.
Progress0 / 4 steps
1
Create the pipeline trigger
Create a YAML file named azure-pipelines.yml and add a trigger section that triggers the pipeline on changes to the main branch.
Azure
Hint
The trigger section tells Azure Pipelines which branches to watch for changes.
2
Add a job with a virtual machine image
Add a jobs section with a job named build that uses the ubuntu-latest virtual machine image.
Azure
Hint
The jobs section defines what work the pipeline will do. The pool specifies the machine to run the job.
3
Add a script step to print a message
Inside the build job, add a steps section with a script step that runs echo Hello, Azure Pipelines!.
Azure
Hint
The steps section lists the commands or tasks the job will run. Use script to run shell commands.
4
Complete and validate the pipeline YAML
Ensure the azure-pipelines.yml file contains the full pipeline with trigger, job, pool, and script step as specified.
Azure
Hint
Check that all parts are present and correctly indented in your YAML file.
Practice
(1/5)
1. What is the main purpose of Azure Pipelines?
easy
A. To automate building, testing, and deploying code
B. To store large amounts of data
C. To create virtual machines
D. To monitor network traffic
Solution
Step 1: Understand Azure Pipelines role
Azure Pipelines automate the process of building, testing, and deploying code changes.
Step 2: Compare options with purpose
Options B, C, and D describe other Azure services, not pipelines.
Final Answer:
To automate building, testing, and deploying code -> Option A
What happens when you push code to the main branch?
medium
A. The pipeline fails due to syntax error
B. The pipeline ignores the push
C. The pipeline runs and prints 'Hello, world!'
D. The pipeline runs but does nothing
Solution
Step 1: Understand trigger configuration
The pipeline triggers on pushes to the 'main' branch as specified.
Step 2: Analyze steps section
The single step runs a script that echoes 'Hello, world!'.
Final Answer:
The pipeline runs and prints 'Hello, world!' -> Option C
Quick Check:
Trigger on main runs echo script [OK]
Hint: Trigger on branch runs defined script [OK]
Common Mistakes:
Assuming pipeline ignores main branch
Thinking pipeline does nothing on trigger
Believing syntax error exists in snippet
4. You wrote this YAML for Azure Pipelines but it never triggers:
trigger:
branches:
exclude:
- main
steps:
- script: echo Build started
What is the likely problem?
medium
A. The pipeline excludes the main branch, so pushes to main don't trigger it
B. The script syntax is incorrect
C. The trigger keyword is misspelled
D. The pipeline requires a separate build agent
Solution
Step 1: Review trigger exclude setting
The pipeline excludes the 'main' branch, so pushes to 'main' won't start it.
Step 2: Check other parts
The script syntax and trigger keyword are correct; no build agent issue is indicated.
Final Answer:
The pipeline excludes the main branch, so pushes to main don't trigger it -> Option A
Quick Check:
Exclude main branch stops trigger [OK]
Hint: Exclude means branch won't trigger pipeline [OK]
Common Mistakes:
Thinking script syntax is wrong
Assuming trigger keyword typo
Believing build agent is missing
5. You want to run tests only when code is pushed to the develop branch and deploy only when code is pushed to main. How should you configure triggers in your Azure Pipelines YAML?
hard
A. Use a single pipeline triggered on both branches and run all steps always
B. Use two separate pipelines: one triggered on 'develop' for tests, another on 'main' for deploy
C. Trigger only on 'main' and manually run tests
D. Trigger only on 'develop' and deploy manually
Solution
Step 1: Understand branch-specific triggers
Running tests and deploy on different branches requires separate triggers.
Step 2: Choose pipeline structure
Two pipelines allow independent triggers and steps per branch, matching requirements.
Step 3: Evaluate other options
Single pipeline running all steps always doesn't separate concerns; manual runs reduce automation benefits.
Final Answer:
Use two separate pipelines: one triggered on 'develop' for tests, another on 'main' for deploy -> Option B
Quick Check:
Separate pipelines for branch-specific tasks [OK]
Hint: Separate pipelines for different branch tasks [OK]
Common Mistakes:
Using one pipeline for all branches without conditions
Triggering only on main and skipping tests automation
Triggering only on develop and missing deploy automation