Microsoft Certified: DevOps Engineer ExpertDesign and implement source controlMedium

A company is developing a complex application with multiple components, each managed by a separate Git repository. They need to create a single Azure DevOps build pipeline that can pull code from these multiple repositories as part of its build process. The main repository contains the pipeline YAML, and other repositories contain libraries or microservices. How should they configure the pipeline to fetch code from these additional repositories?

  1. AUse the 'checkout' step with multiple 'repository' resources.
  2. BConfigure separate 'Get Sources' tasks for each repository in the classic editor.
  3. CAdd 'Git clone' commands as separate script tasks for each repository.
  4. DUtilize Git submodules within the main repository.
Show answer & explanation

Correct answer: A. Use the 'checkout' step with multiple 'repository' resources.

In YAML pipelines, the 'checkout' step can be configured with multiple 'repository' resources. This allows the pipeline to fetch code from several Git repositories (within the same organization or external) into the agent's workspace, enabling a single pipeline to orchestrate builds across multiple codebases.

Why the other options are wrong

  • B. 'Get Sources' tasks are for classic pipelines; the question implies a YAML pipeline context with 'pipeline YAML'.
  • C. Using 'Git clone' commands in script tasks is a less integrated and more manual approach compared to the built-in 'checkout' step, and it might complicate authentication.
  • D. Git submodules are a source control feature for linking repositories, but in Azure DevOps pipelines, directly checking out multiple repositories is often simpler for build purposes than managing submodules.

Azure DevOps Multi-Repo Checkout

The ability of an Azure DevOps YAML pipeline to pull code from multiple Git repositories (beyond the one containing the pipeline definition) into the build agent's workspace.

  • Enabled by defining multiple 'repository' resources and using 'checkout' steps.
  • Facilitates monorepo-like builds or integrating shared libraries.
  • Supports repositories within the same organization or external (GitHub, Bitbucket).

Memory trick: Imagine your pipeline as a chef. Instead of just picking ingredients from one garden, it can 'checkout' ingredients from many different gardens (repositories) to cook a single meal (build).

More Design and implement source control questions