Requiring Team-Specific Approval for Monorepo Subfolder Changes
You need to create a pipeline that triggers only when changes are made to files in the 'src/api' folder. Which trigger configuration should you use?
⚠ Common exam trap
Test-takers frequently confuse `include` with `exclude` or forget that path filters require explicit `include` statements to restrict triggers, leading them to pick option B which does the opposite of what is asked.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
trigger: paths: include: - 'src/api/*'
The `trigger: paths: include: - 'src/api/*'` configuration tells Azure Pipelines to only trigger the pipeline when changes are detected in files matching that path pattern. This is the standard way to scope pipeline triggers to specific folders or file patterns in YAML pipelines, ensuring that unrelated changes elsewhere in the repository do not start the pipeline.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
trigger: branches: include: - 'main'
Why it's wrong here
The `branches` filter controls which Git branches should trigger the pipeline, not which file paths. Configuring `include: 'main'` means the pipeline will trigger on any commit pushed to `main`, regardless of which files were changed—so it would still run for changes outside `src/api`, failing the 'only when changes to that path' requirement.
- ✗
trigger: paths: exclude: - 'src/api/*'
Why it's wrong here
The `paths` filter with `exclude` does the opposite of what is needed: it tells the pipeline to *ignore* commits that modify files under `src/api/*`. As a result, the pipeline would trigger only when changes are made to other paths, and would *not* trigger when changes directly affect `src/api/*`—exactly the opposite of the desired behavior.
- ✗
trigger: tags: include: - 'v*'
Why it's wrong here
The `tags` filter triggers the pipeline when a Git tag matching the pattern (e.g., `v*`) is created, not when code changes occur in a particular directory. This is unrelated to file-path-based triggering, so it would not restrict runs to changes under `src/api/*`.
- ✓
trigger: paths: include: - 'src/api/*'
Why this is correct
The `paths` filter with `include` is correct because it defines a file-path allowlist: the pipeline only triggers when a commit changes files under the `src/api/*` path. This ensures the pipeline runs exclusively when modifications occur in that directory, satisfying the requirement to trigger only on changes to `src/api`.
Go deeper
Related to this question
Learn chapter
Implementing Security and Compliance in Pipelines
Key term
Azure Pipelines
Azure Pipelines is a cloud-based CI/CD service from Microsoft that automatically builds, tests, and deploys code to any platform or cloud.
Key term
Repository
A repository is a central storage location where software packages, code, or configuration files are kept, managed, and distributed for use by IT systems.
About these practice questions
One of 696 original AZ-400 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
6 more ways this is tested on AZ-400
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. You have an Azure Pipelines YAML file with the following trigger configuration: ```yaml trigger: branches: include: - main paths: include: - /src/* ``` The team reports that the pipeline does not trigger when changes are pushed to the main branch that modify files outside the /src folder. What is the most likely reason?
medium- ✓ A.The path filter restricts the trigger to only changes in /src/.
- B.The trigger syntax is incorrect; 'branch' should be 'branches'.
- C.The script step is missing a display name.
- D.The pool vmImage is not specified correctly.
Why A: The most likely reason is that a path filter is configured in the trigger, restricting the pipeline to only trigger on changes under /src/. The other options are incorrect because they either refer to minor syntax issues or irrelevant details.
Variation 2. You are designing a build pipeline that must be triggered only when changes are made to specific folders in the repository. The pipeline should ignore documentation changes. Which trigger configuration should you use?
hard- A.Configure a scheduled trigger to run the pipeline daily.
- B.Configure a branch trigger with an include filter for the main branch.
- ✓ C.Configure a path trigger with include paths for source code and exclude paths for docs.
- D.Configure a tag trigger with a pattern that matches release tags.
Why C: Azure Pipelines path triggers allow you to specify include and exclude filters on file paths. By including only source code folders and excluding the docs folder, the pipeline will only run when relevant code changes are made, ignoring documentation updates.
Variation 3. Refer to the exhibit. You have an Azure Pipelines YAML file for a .NET Core application. The pipeline is triggered on changes to the main branch, but only for files under src/. After a push to main that modifies a file in src/, the pipeline does not start. What is the most likely reason?
medium- A.The branch filter is missing the 'refs/heads/' prefix.
- B.The trigger configuration has a syntax error: 'include' should be 'includes'.
- C.The variable 'buildConfiguration' is not defined at the top level.
- ✓ D.The path filter 'src/*' does not match files in subdirectories of src/.
Why D: The path filter `src/*` uses a single asterisk, which only matches files directly within the `src/` directory, not files in subdirectories (e.g., `src/app/main.cs`). Azure Pipelines path filters require a double asterisk `src/**` to recursively match all files under `src/`. Since the modified file is in a subdirectory, the trigger condition is not met, and the pipeline does not start.
Variation 4. Your team uses a YAML-based build pipeline in Azure Pipelines. You need to ensure that the pipeline runs automatically when a pull request is created against the main branch, but only if the changes include modifications to the 'src/' directory. Which trigger configuration should you use?
medium- A.trigger: - main; pr: none
- ✓ B.trigger: none; pr: branches: include: - main paths: include: - src/*
- C.trigger: none; pr: - main
- D.pr: - main; trigger: - main
Why B: It sets `trigger: none` to disable CI triggers on commits, and uses a PR trigger with `branches: include: - main` and `paths: include: - src/*` to ensure the pipeline only runs automatically when a pull request targets the main branch and the changes include modifications to the 'src/' directory. This configuration meets the requirement of conditional PR-triggered builds based on file paths.
Variation 5. You need to configure a build pipeline that triggers only when changes are pushed to the 'release/*' branch. Which trigger configuration should you use?
easy- A.Set 'trigger: none' in YAML
- ✓ B.Set 'trigger: branches: include: - release/*'
- C.Set 'trigger: branches: include: - main'
- D.Set 'trigger: tags: include: - v*'
Why B: The YAML trigger configuration 'trigger: branches: include: - release/*' explicitly specifies that the pipeline should run only when changes are pushed to any branch matching the 'release/*' wildcard pattern. This is the standard way to define branch-based triggers in Azure Pipelines YAML, ensuring that only pushes to release branches initiate the build.
Variation 6. You have a multi-stage YAML pipeline that builds and deploys a Node.js application. You want to ensure that the build stage runs only when changes are made to the 'src' folder. Which trigger configuration should you use?
easy- A.Trigger with 'batch' set to true
- B.Trigger with 'branches' filter
- ✓ C.Trigger with 'paths' filter
- D.Disable CI trigger and use a scheduled trigger
Why C: Azure Pipelines supports path-based triggers that allow you to specify which file paths should trigger a pipeline run. By configuring a trigger with a 'paths' filter that includes only the 'src' folder, the build stage will only execute when changes are detected within that specific directory, ignoring changes elsewhere in the repository.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AZ-400 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-400 exam.