Microsoft Certified: DevOps Engineer ExpertDesign and implement source controlHard

A company is adopting a monorepo strategy for its microservices. Each microservice has its own folder within the single Git repository (e.g., /src/serviceA, /src/serviceB). They want to create a single Azure DevOps YAML pipeline that can build only the microservice whose code has changed in a given commit, rather than building all microservices every time. Which pipeline feature should they use to achieve this optimized build behavior?

  1. AScheduled triggers for each microservice
  2. BPath filters in CI triggers
  3. CConditional expressions in pipeline tasks
  4. DMultiple pipeline definitions, one per microservice
Show answer & explanation

Correct answer: B. Path filters in CI triggers

Path filters in Continuous Integration (CI) triggers allow a pipeline to be triggered only when changes occur in specific paths within the repository. By configuring a path filter for each microservice's directory, the pipeline can conditionally build only the affected microservice, optimizing build times in a monorepo.

Why the other options are wrong

  • A. Scheduled triggers run at fixed intervals and do not react to code changes, making them unsuitable for building only changed microservices dynamically.
  • C. Conditional expressions can control task execution *within* a running pipeline, but they don't prevent the entire pipeline from triggering unnecessarily when only unrelated code changes.
  • D. While possible, creating multiple pipeline definitions for a single monorepo complicates management and doesn't fully leverage the 'single pipeline that builds only changed microservices' aspect.

CI Trigger Path Filters (Monorepo)

A configuration within a Continuous Integration (CI) trigger in Azure DevOps pipelines that specifies which file paths, when changed, should cause the pipeline to run.

  • Essential for optimizing builds in monorepos.
  • Prevents unnecessary builds of unaffected components.
  • Can include and exclude specific paths.

Memory trick: Imagine a monorepo as a giant tree. Path filters are like a smart gardener who only prunes (builds) the branches that have actually grown (changed code).

More Design and implement source control questions