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