Courseiva
Design and implement build and release pipelineseasyMultiple ChoiceObjective-mapped

AZ-400 Practice Question: Design and implement build and release pipelines

Your team uses Azure Pipelines for CI/CD. You want to enforce that every build produces a versioned artifact that includes the Git commit ID. Which predefined variable should you use to get the commit ID in a YAML pipeline?

⚠ Common exam trap

Many exam-takers confuse `Build.BuildId` (a pipeline run counter) with a Git commit identifier, or assume `Build.SourceBranch` contains the commit hash because it includes 'Source' in its name.

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

Build.SourceVersion

The `Build.SourceVersion` predefined variable in Azure Pipelines resolves to the commit ID (full SHA) of the commit that triggered the pipeline. This makes it the correct choice for embedding the Git commit ID into a versioned artifact. Other variables like `Build.BuildId` or `Build.SourceBranch` do not provide the commit hash.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Build.Repository.Name

    Why it's wrong here

    Build.Repository.Name identifies the Azure Repos or GitHub repository name (e.g., 'my-repo'), not the specific commit. Since the requirement is to enforce something based on the exact commit, this variable does not provide the commit hash and is therefore incorrect.

  • Build.BuildId

    Why it's wrong here

    Build.BuildId is a unique numeric identifier for a specific pipeline run, not the source commit ID. It cannot be used to reference the exact commit in the repository, so it does not meet the requirement for commit-level enforcement.

  • Build.SourceVersion

    Why this is correct

    Build.SourceVersion contains the full commit ID (SHA) of the source that triggered the pipeline. This is the appropriate predefined variable to enforce policies, tag builds, or take actions based on the exact commit, making it the correct answer.

  • Build.SourceBranch

    Why it's wrong here

    Build.SourceBranch captures the ref path of the triggering branch (e.g., refs/heads/main or refs/heads/feature/x). Because a branch is a mutable pointer that advances with each push, multiple pipeline runs can execute against the same branch value while referring to different commits. Consequently, using Build.SourceBranch cannot identify a specific commit state, making it unsuitable for enforcing requirements that depend on the exact commit, such as gating on a particular SHA.

Visual reference

Client Recursive Resolver Root DNS (13 root servers) TLD DNS (.com, .org, …) Authoritative example.com query IP addr answer

About these practice questions

Courseiva writes every AZ-400 question from scratch — 823 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.