To run automated tests with Google Cloud Build, add a build step to cloudbuild.yaml that invokes your project’s test command in a container with the right runtime and tools. Put that step before packaging, publishing, or deployment steps so a failed test stops the build before those actions run. You can start the build manually or connect it to a repository trigger.
How Cloud Build runs tests
Cloud Build reads a YAML or JSON build configuration and runs its steps in containers. A test is an ordinary build step: choose an image containing the required runtime and tooling, then invoke the command your project already uses. The same configuration can run dependency setup, unit tests, static analysis, integration tests, and artifact creation.
As an Amazon Associate I earn from qualifying purchases.
Build steps run serially by default. If tests are a release gate, place them before any step that builds or publishes a release artifact or deploys it. See Google Cloud’s Cloud Build overview.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchAdd a test step to cloudbuild.yaml
Create cloudbuild.yaml in your project root. The smallest useful configuration has a step with a runtime image and a test command. Match the image and dependency setup to your application; a floating image tag such as latest can change over time, so pin a tag when reproducible environments matter.
#1 Best Overall
steps:
- name: 'python'
entrypoint: 'python'
args: ['-m', 'pytest']
This example runs pytest and relies on dependencies being available in the image or installed by an earlier step. Adapt the setup to your project. Google’s guide to running tests documents language-specific patterns.
Use the test command for your language
Python
Run pytest through Python’s module interface. To have pytest write a JUnit XML report as well as return a test status, add the report option:
steps:
- name: 'python'
entrypoint: 'python'
args: ['-m', 'pytest', '--junitxml=${SHORT_SHA}_test_log.xml']
Node.js
If your package.json defines a test script, install dependencies and run it in a Node.js image:
steps:
- name: 'node'
entrypoint: 'npm'
args: ['install']
- name: 'node'
entrypoint: 'npm'
args: ['test']
Use the dependency installation process appropriate for your project and lockfile; the important part is that the test step has the required dependencies and invokes the project’s test script.
Go
The basic Go test step invokes go test. Google’s example pipes verbose output through go-junit-report when an XML report is wanted, using -set-exit-code so a failing test remains a failing build step. Configure the formatter and its installation for your selected image and Go toolchain; do not let a pipeline hide the test command’s nonzero exit status.
steps:
- name: 'golang'
entrypoint: 'go'
args: ['test', './...']
See Google’s language examples for test steps for the documented report-generation pattern.
Rank #2
Keep test failures from reaching later steps
A normal test command exits unsuccessfully when tests fail, which makes its build step fail. Because steps run serially by default, later packaging, publication, or deployment steps do not run after that failure. Keep test status visible if you wrap a command in a shell script or pipeline: a wrapper that exits successfully despite failed tests defeats the gate.
For example, when piping Go test output into a report formatter, use a setup that propagates the test failure. Google’s documented Go pattern uses -set-exit-code with go-junit-report for that purpose.
Generate and store a JUnit XML report
Generating a report and storing it are separate choices. A test runner may write JUnit XML locally, but Cloud Storage persistence requires an artifact declaration in the build configuration and a valid bucket destination.
steps:
- name: 'python'
entrypoint: 'python'
args: ['-m', 'pytest', '--junitxml=${SHORT_SHA}_test_log.xml']
artifacts:
objects:
location: 'gs://${_BUCKET_NAME}/'
paths:
- '${SHORT_SHA}_test_log.xml'
Before using this pattern, create the bucket and ensure the build’s service account has permission to write objects there. Google’s Python guide identifies the Cloud Storage Object Creator role among the prerequisites. A report file is an artifact you can retain separately; the build’s normal logs remain useful for diagnosing the command itself. The reviewed documentation does not establish a particular automatic report viewer or test dashboard. See Google’s report and test configuration examples and Cloud Build artifact storage documentation.
Run a build manually
Once the configuration is in the project root, submit a build with the Google Cloud CLI:
Free tools Windows power users keep installed
One-click scans. No signup required.
gcloud builds submit
Cloud Build runs the configured steps and shows build details and logs in Build History. Manual submission is useful for an ad hoc run before connecting automation. If configuration values vary by run, pass user-defined substitutions:
Rank #3
gcloud builds submit --substitutions=_BUCKET_NAME=your-bucket
Define any user substitutions in the build configuration and replace the example bucket value with your actual destination. Built-in substitutions such as $PROJECT_ID and $SHORT_SHA can provide build-specific values. See Google’s substitutions documentation.
Run tests automatically with a repository trigger
For continuous integration, create a Cloud Build trigger tied to your repository and choose an event such as a push to a branch. Configure the trigger to use the build configuration in the repository; trigger settings can also supply substitutions. A push then starts the build, and the test step runs as part of the configured sequence.
-
Open Cloud Build and create a build trigger.
-
Connect or select the repository and choose the event and branch pattern that should start a build.
Recommended: Fix Windows Errors and Clear Junk Files in Minutes - Free Scan →Recommended: Crashes or Glitches? A Free Driver Scan Usually Finds the Culprit →Recommended: PC Feels Slow? A Free Scan Shows What's Dragging Windows Down →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Point the trigger at your
cloudbuild.yamlconfiguration. -
Set any required trigger substitutions, such as a bucket name used for report storage.
-
Save the trigger, push a change matching its event settings, and inspect the resulting build in Build History.
Exact console labels and trigger availability can vary with repository connection and Cloud Build configuration. Google’s Cloud Build quickstart demonstrates a push-to-branch trigger and reviewing build history.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Use substitutions for changing values
Substitutions let a build configuration use values that differ between builds, such as a project identifier, commit identifier, or report bucket. Built-in variables include $PROJECT_ID and $SHORT_SHA; user-defined variables use names beginning with an underscore, such as ${_BUCKET_NAME}. Set user-defined values on a manual submission or in trigger settings, and ensure the configuration declares the variables it uses.
Substitutions are configuration values, not a substitute for handling secrets. The cited substitutions guide explains variable substitution; it does not establish a secret-management recommendation.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Inspect results and troubleshoot failures
Open the build’s details and logs through Cloud Build History or use the CLI/API to inspect the execution. The logs show which step failed and its output; a stored JUnit XML file provides a separate machine-readable result artifact if you configured storage.
-
The runtime or command is missing: Check that the step’s image contains the required language runtime and test tooling, and that the command is valid for that image.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Dependencies are unavailable: Add or correct the dependency-install step, and confirm it completes before the test step.
-
The command passes locally but fails in Cloud Build: Compare the configured image, working directory, environment, and dependency process with the local setup; inspect the failing step’s logs.
-
Later steps run despite failed tests: Check shell wrappers and pipelines for masked exit codes. Ensure the test step returns a nonzero status on failure; for the documented Go report pipeline, use the formatter option that propagates the exit status.
-
The XML file is not retained: Confirm the test command actually writes the path named in
artifacts.objects.paths, the bucket exists, and the build service account has permission to create objects there.Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesSpecial offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
The build cannot write to the bucket: Verify the bucket location and the selected build service account’s storage permissions. Report generation alone does not upload the report.
Or skip the browser setup
If your pipeline also needs website screenshots, ScreenshotNeo provides a screenshot API and MCP server; it is separate from Cloud Build test execution. One GET request can return an image or PDF. For example, save a WebP screenshot with cURL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. Cookie banners, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed. An MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo free.
Frequently Asked Questions
Does Cloud Build require a specific test framework?
No. Use the command and runtime image that fit your project; the documented examples include pytest, npm test, and go test.
Recommended Free Tools
Does Cloud Build automatically upload JUnit XML when a test creates it?
No. Configure an artifact destination and paths, and provide a bucket with the required write permissions.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




