Configuring Cloud Build Triggers for Semantic Versioning

PCDOE By islever Editorial Last updated

Designing pipelines.

Short answer

A Create a build trigger with the \d+.\d+.\d+ tag pattern.

Question

You recently created a Cloud Build pipeline for deploying Terraform code stored in a GitHub repository. You make Terraform code changes in short-lived branches and sometimes use tags during development. You tag releases with a semantic version when they are ready for deployment. You require your pipeline to apply the Terraform code whenever there is a new release, and you need to minimize operational overhead. What should you do?
  1. Create a build trigger with the \d+\.\d+\.\d+ tag pattern. Correct Answer
  2. Create a build trigger with the \d+\.\d+\.\d+ branch pattern.
  3. Create a build trigger with the .* tag pattern.
  4. Create a build trigger with the .* branch pattern.

Key Takeaways

The question tests the ability to map semantic versioning requirements to Cloud Build trigger filters, specifically distinguishing between branch and tag patterns.

This page explains how to configure a Google Cloud Build trigger to deploy Terraform code based on semantic versioning tags while minimizing operational overhead. It establishes that using a precise regex pattern for tag creation is the correct approach.

Common mistake: Learners often confuse branch patterns with tag patterns or choose overly broad patterns like '.*' which increases overhead and risk by triggering on every commit or tag.

Expert Analysis

Why the Answer Is Correct

Option A is correct because it specifies a build trigger configured for tags (not branches) using the regular expression \d+\.\d+\.\d+. This regex precisely matches semantic versioning formats (e.g., 1.0.0, 2.1.3), ensuring the pipeline only runs when a new release tag is created. This aligns perfectly with the requirement to apply Terraform on new releases while minimizing operational overhead by ignoring non-release commits.

Why the Other Options Are Wrong

Option B uses the same regex but applies it to branches. The scenario explicitly states releases are tagged, not necessarily deployed from specific named branches. Option C (. tag) would trigger on every tag, including development tags, increasing operational overhead and potentially causing premature deployments. Option D (. branch) would trigger on every branch change, violating the requirement to minimize overhead and deploy only on releases.

Community Comment Notes

Community consensus strongly supports Option A. As user mT3 noted, "By specifying the tag pattern as a regular expression \d+.\d+.\d+ in the Cloud Build trigger, deployments based on Semantic Versioning tags are possible." Another learner, BlackCoffee, confirmed, "A is the right one based on semantic version format and tags," highlighting the direct mapping between the requirement and the regex syntax.

Official Reference

https://cloud.google.com/build/docs/automate-builds-triggers#adding_triggers

This link opens the official vendor documentation in a new tab.

Exam Strategy

When configuring triggers for specific events like releases, always verify if the event is a branch push or a tag creation. Use precise regular expressions to match the expected data format (like semver) to avoid unintended triggers and reduce operational noise.

Frequently Asked Questions

Why not use .* tag pattern?

Using .* triggers on all tags, including development ones, which violates the 'minimize overhead' requirement and risks deploying untested code.

Can I use branch patterns for releases?

No, the scenario specifies releases are tagged. Using branch patterns would ignore the tag-based deployment strategy required.

More PCDOE FAQ →

Discussion 2 contributions

Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.

From public community threads 2

  1. mT3 👍 2 Answered A
    The requirement is to use semantic versioning tags (e.g., 1.2.3) in releases and to apply Terraform when those tags are created. By specifying the tag pattern as a regular expression \d+\.\d+\.\d+ in the Cloud Build trigger, deployments based on Semantic Versioning tags are possible.
  2. BlackCoffee 👍 1 Answered A
    A is the right one based on semantic version format and tags

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

Practice All PCDOE Questions

Access 75 questions with complete answers and detailed explanations.

View Full PCDOE Practice Test →

← Back to PCDOE Study Guide