Microsoft Certified: DevOps Engineer ExpertDesign and implement source controlEasy

A development team is using Azure DevOps for their source control and build pipelines. They have a large monorepo containing multiple independent services. The team wants to ensure that build pipelines are only triggered for a specific service when changes are made to that service's directory. They also want to include changes to a common shared library in a `shared/libs` directory that all services depend on. Which configuration should they use in their Azure Pipelines YAML definition?

  1. A```yaml trigger: paths: include: - serviceA/** - shared/libs/** ```
  2. B```yaml trigger: branches: include: - main paths: include: - serviceA/** exclude: - shared/libs/** ```
  3. C```yaml trigger: paths: include: - serviceA/** exclude: - shared/libs/** ```
  4. D```yaml trigger: branches: include: - main paths: include: - serviceA/** - shared/libs/** ```
Show answer & explanation

Correct answer: D. ```yaml trigger: branches: include: - main paths: include: - serviceA/** - shared/libs/** ```

The team wants to trigger the build for 'serviceA' when changes are made to 'serviceA/**' or 'shared/libs/**'. The 'trigger.paths.include' section is used to specify which paths should trigger the pipeline. Option D correctly includes both paths and specifies the 'main' branch, which is a common practice.

Why the other options are wrong

  • A. This option is missing the branch specification, which is usually included for clarity and control.
  • B. This option incorrectly excludes 'shared/libs/**' when it should be included.
  • C. This option is missing the branch specification and incorrectly excludes 'shared/libs/**'.

Azure Pipelines Path Filters

Path filters in Azure Pipelines YAML allow you to specify which file paths trigger a CI build, enabling selective pipeline execution based on code changes.

  • Defined under the `trigger.paths` section.
  • Use `include` to specify paths that trigger a build.
  • Use `exclude` to specify paths that should not trigger a build.
  • Wildcards like `**` (any sub-directory) and `*` (any character) are supported.

Memory trick: Path to success is to include all dependencies.

More Design and implement source control questions