Microsoft Certified: DevOps Engineer ExpertDesign and implement source controlMedium
A team is developing a large application with several independent components, each residing in its own Git repository in Azure Repos. A build pipeline for the main application needs to access code from multiple repositories (e.g., common libraries, configuration files) during its execution. How should the pipeline be configured to efficiently check out code from these additional repositories?
- AConfigure the pipeline to run on an agent that has all repositories pre-cloned.
- BAdd multiple 'Get Sources' tasks to the pipeline, one for each repository.
- CUse the 'checkout' step with multiple repository resources in the YAML pipeline.
- DManually clone each additional repository using Git commands in a script task.
Show answer & explanationAnswer & explanation
Correct answer: C. Use the 'checkout' step with multiple repository resources in the YAML pipeline.
Azure DevOps YAML pipelines support defining multiple repository resources and then checking them out using the 'checkout' step. This is the native and most efficient way to access code from multiple Git repositories within a single pipeline run.
Why the other options are wrong
- A. Pre-cloning on agents is not scalable or practical, as agents are often ephemeral or shared, and it doesn't ensure the correct branch/commit.
- B. While possible in classic editor, in YAML, the 'checkout' step with repository resources is the idiomatic and cleaner approach.
- D. Manual Git commands are less efficient, harder to maintain, and don't leverage native pipeline features for multiple repos.
Azure DevOps Multi-Repo Checkout
A feature in Azure DevOps YAML pipelines that allows a single pipeline to check out code from multiple Git repositories (both Azure Repos and external) into the agent's workspace.
- Defined using `resources.repositories` in YAML.
- Supports different repository types (Git, GitHub, Bitbucket).
- Each repository is checked out into a specific directory.
Memory trick: Check out all the books from the library for your project.