Stay organized with collections
Save and categorize content based on your preferences.
This page explains how you can store build artifacts in Cloud Storage.
We recommend using Artifact Registry for storing build artifacts. Artifact Registry is a
Google Cloud product that you can integrate with Cloud Build
to securely store and manage your artifacts in private or public repositories.
Storing artifacts in Artifact Registry enables you to:
Manage container metadata and scan for container vulnerabilities with
Artifact Analysis.
For instructions on configuring Cloud Build to store packages and images
from your builds in Artifact Registry, see
Store artifacts in Artifact Registry.
Storing artifacts in Cloud Storage
To store non-container artifacts in Cloud Storage, add an artifacts
field in your build config file with the location of the bucket to store the
artifact and the path to one or more artifacts:
[STORAGE_LOCATION]: A Cloud Storage bucket or a folder within the
bucket where Cloud Build must store the artifact, such as
gs://mybucket or gs://mybucket/myproject/builds. To find the names
of existing buckets, see list buckets
or create a new bucket.
[ARTIFACT_PATH]: Path to one or more artifacts. [ARTIFACT_PATH] is
relative to your working directory. This can be either /workspace,
which is Cloud Build's default working directory or the working
directory you set using the dir
field.
[STORAGE_LOCATION]: A Cloud Storage bucket or a folder within the
bucket where Cloud Build must store the artifact, such as
gs://mybucket or gs://mybucket/myproject/builds. To find the names of
existing buckets, see list buckets or
create a new bucket.
[ARTIFACT_PATH]: Path to one or more artifacts. [ARTIFACT_PATH] is
relative to your working directory. This can be either /workspace,
which is Cloud Build's default working directory or the working
directory you set using the dir
field.
Note the following caveats when storing artifacts in Cloud Storage:
You can specify only one bucket to upload the artifacts and you must be the
owner of the bucket. You can specify a valid directory path in the bucket.
You can upload any number of artifacts, but you can specify only up to one
hundred artifact paths.
If you upload an artifact to a bucket that already has an artifact with the same
name, the new artifact will replace the existing artifact. You can enable
Object Versioning for your bucket if you
don't want the newer artifact to replace an existing artifact with the same
name.
After the build completes successfully, you can find the upload results in the
JSON manifest file located at [STORAGE_LOCATION]/artifacts-$BUILD_ID.json.
The JSON manifest file has the following fields:
location: this specifies the location in Cloud Storage where an
artifact is stored and is of the form
gs://[STORAGE_LOCATION]/[FILE_NAME]#[GENERATION_NUMBER]. You can use the
generation number to uniquely
identify a version of the data in Cloud Storage bucket.
file_hash: this specifies the hash type and the value. The hash type is
always 2, which specifies that MD5 hash was performed.
Artifacts examples
The following examples show how you can use the Artifacts field in a build
config file. In all of these examples replace [VALUES_IN_BRACKETS] with the
appropriate values.
Uploading files and folders
The build config file below uploads helloworld.class to
thegs://[STORAGE_LOCATION]/:
To upload more than one artifact, specify the path to each artifact separated by
a comma. The following example uploads HelloWorld.java, HelloWorld.class,
and cloudbuild.yaml to gs://[STORAGE_LOCATION]/:
You can also upload the artifacts to a valid directory path in the bucket. The
following example uploads HelloWorld.java and HelloWorld.class to
gs://[BUCKET_NAME]/[FOLDER_NAME]:
Using wildcard characters to upload more than one artifact
When uploading multiple artifacts, you can use
wildcard characters in paths to specify multiple
files.
The following example takes as an argument a file named classes, which
contains the names of the .java files to compile. It then uploads any .class
file to the specified Cloud Storage bucket:
Using substitution variables in the bucket location
You can use substitution
variables
to specify a folder within the Cloud Storage bucket. If the folder you've
specified doesn't exist, Cloud Build will create it for you.
The example below uploads the artifacts to a Cloud Storage path that
includes the name of your Google Cloud project from which the build was run
(such as gs://mybucket/myproject/):
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThis document explains how to store non-container build artifacts in Cloud Storage by adding an \u003ccode\u003eartifacts\u003c/code\u003e field to your build config file, which includes the storage location and artifact paths.\u003c/p\u003e\n"],["\u003cp\u003eWhen storing artifacts in Cloud Storage, you can only specify one bucket, you must be the owner, you can upload up to one hundred artifact paths, and new artifacts with the same name will replace the old one unless object versioning is enabled.\u003c/p\u003e\n"],["\u003cp\u003eThe build's upload results are stored in a JSON manifest file with the \u003ccode\u003elocation\u003c/code\u003e of the artifact and its \u003ccode\u003efile_hash\u003c/code\u003e available once the build is successful.\u003c/p\u003e\n"],["\u003cp\u003eYou can upload single or multiple artifacts, including folders, using specified paths or wildcard characters in the build configuration.\u003c/p\u003e\n"],["\u003cp\u003eThe storage location in Cloud Storage can include substitution variables, allowing for dynamic path creation, like including the project ID in the folder name.\u003c/p\u003e\n"]]],[],null,["# Storing build artifacts in Cloud Storage\n\nThis page explains how you can store build artifacts in Cloud Storage.\n\nWe recommend using Artifact Registry for storing build artifacts. Artifact Registry is a\nGoogle Cloud product that you can integrate with Cloud Build\nto securely store and manage your artifacts in private or public repositories.\nStoring artifacts in Artifact Registry enables you to:\n\n- Manage container metadata and scan for container vulnerabilities with [Artifact Analysis](/artifact-analysis/docs).\n- Enforce deployment policies with [Binary Authorization](/binary-authorization/docs).\n- [Use image streaming in Google Kubernetes Engine](/kubernetes-engine/docs/how-to/image-streaming), which is particularly beneficial for large container images.\n\nFor instructions on configuring Cloud Build to store packages and images\nfrom your builds in Artifact Registry, see\n[Store artifacts in Artifact Registry](/build/docs/building/store-artifacts-in-artifact-registry).\n\nStoring artifacts in Cloud Storage\n----------------------------------\n\n**To store non-container artifacts in Cloud Storage** , add an `artifacts`\nfield in your build config file with the location of the bucket to store the\nartifact and the path to one or more artifacts: \n\n### YAML\n\n artifacts:\n objects:\n location: [STORAGE_LOCATION]\n paths: [[ARTIFACT_PATH],[ARTIFACT_PATH], ...]\n\nWhere,\n\n- `[STORAGE_LOCATION]`: A Cloud Storage bucket or a folder within the bucket where Cloud Build must store the artifact, such as `gs://mybucket` or `gs://mybucket/myproject/builds`. To find the names of existing buckets, see [list buckets](/storage/docs/listing-buckets) or [create a new bucket](/storage/docs/creating-buckets).\n- `[ARTIFACT_PATH]`: Path to one or more artifacts. `[ARTIFACT_PATH]` is relative to your working directory. This can be either `/workspace`, which is Cloud Build's default working directory or the working directory you set using the [`dir`](/build/docs/build-config-file-schema#build_steps) field.\n\n### JSON\n\n {\n \"artifacts\": {\n \"objects\": {\n \"location\": [\n \"[STORAGE_LOCATION]\"\n ],\n \"paths\": [\n [\n \"[ARTIFACT_PATH]\"\n ],\n [\n \"[ARTIFACT_PATH]\"\n ],\n \"...\"\n ]\n }\n }\n }\n\nWhere,\n\n- `[STORAGE_LOCATION]`: A Cloud Storage bucket or a folder within the bucket where Cloud Build must store the artifact, such as `gs://mybucket` or `gs://mybucket/myproject/builds`. To find the names of existing buckets, see [list buckets](/storage/docs/listing-buckets) or [create a new bucket](/storage/docs/creating-buckets).\n- `[ARTIFACT_PATH]`: Path to one or more artifacts. `[ARTIFACT_PATH]` is relative to your working directory. This can be either `/workspace`, which is Cloud Build's default working directory or the working directory you set using the [`dir`](/build/docs/build-config-file-schema#build_steps) field.\n\nNote the following caveats when storing artifacts in Cloud Storage:\n\n- You can specify only one bucket to upload the artifacts and you must be the\n owner of the bucket. You can specify a valid directory path in the bucket.\n\n- You can upload any number of artifacts, but you can specify only up to one\n hundred artifact paths.\n\n- If you upload an artifact to a bucket that already has an artifact with the same\n name, the new artifact will replace the existing artifact. You can enable\n [Object Versioning](/storage/docs/object-versioning) for your bucket if you\n don't want the newer artifact to replace an existing artifact with the same\n name.\n\nAfter the build completes successfully, you can find the upload results in the\nJSON manifest file located at `[STORAGE_LOCATION]/artifacts-$BUILD_ID.json`.\n\nThe JSON manifest file has the following fields:\n\n- `location`: this specifies the location in Cloud Storage where an artifact is stored and is of the form `gs://[STORAGE_LOCATION]/[FILE_NAME]#[GENERATION_NUMBER]`. You can use the [generation number](/storage/docs/metadata#generation-number) to uniquely identify a version of the data in Cloud Storage bucket.\n- `file_hash`: this specifies the hash type and the value. The hash type is always 2, which specifies that MD5 hash was performed.\n\nArtifacts examples\n------------------\n\nThe following examples show how you can use the `Artifacts` field in a build\nconfig file. In all of these examples replace `[VALUES_IN_BRACKETS]` with the\nappropriate values.\n\n### Uploading files and folders\n\nThe build config file below uploads `helloworld.class` to\nthe`gs://[STORAGE_LOCATION]/`: \n\n### YAML\n\n steps:\n - name: 'gcr.io/cloud-builders/javac'\n args: ['HelloWorld.java']\n artifacts:\n objects:\n location: 'gs://[STORAGE_LOCATION]/'\n paths: ['HelloWorld.class']\n\n### JSON\n\n {\n \"steps\": [\n {\n \"name\": \"gcr.io/cloud-builders/javac\",\n \"args\": [\n \"HelloWorld.java\"\n ]\n }\n ],\n \"artifacts\": {\n \"objects\": {\n \"location\": \"gs://[STORAGE_LOCATION]/\",\n \"paths\": [\n \"HelloWorld.class\"\n ]\n }\n }\n }\n\nTo upload more than one artifact, specify the path to each artifact separated by\na comma. The following example uploads `HelloWorld.java`, `HelloWorld.class`,\nand `cloudbuild.yaml` to `gs://[STORAGE_LOCATION]/`: \n\n### YAML\n\n steps:\n - name: 'gcr.io/cloud-builders/javac'\n args: ['HelloWorld.java']\n artifacts:\n objects:\n location: 'gs://[STORAGE_LOCATION]/'\n paths: ['HelloWorld.java', 'HelloWorld.class', 'cloudbuild.yaml']\n\n### JSON\n\n {\n \"steps\": [\n {\n \"name\": \"gcr.io/cloud-builders/javac\",\n \"args\": [\n \"HelloWorld.java\"\n ]\n }\n ],\n \"artifacts\": {\n \"objects\": {\n \"location\": \"gs://[STORAGE_LOCATION]/\",\n \"paths\": [\n \"HelloWorld.java\",\n \"HelloWorld.class\",\n \"cloudbuild.yaml\"\n ]\n }\n }\n }\n\nYou can also upload the artifacts to a valid directory path in the bucket. The\nfollowing example uploads `HelloWorld.java` and `HelloWorld.class` to\n`gs://[BUCKET_NAME]/[FOLDER_NAME]`: \n\n### YAML\n\n steps:\n - name: 'gcr.io/cloud-builders/javac'\n args: ['HelloWorld.java']\n artifacts:\n objects:\n location: 'gs://[BUCKET_NAME]/[FOLDER_NAME]'\n paths: ['HelloWorld.java', 'HelloWorld.class']\n\n### JSON\n\n {\n \"steps\": [\n {\n \"name\": \"gcr.io/cloud-builders/javac\",\n \"args\": [\n \"HelloWorld.java\"\n ]\n }\n ],\n \"artifacts\": {\n \"objects\": {\n \"location\": \"gs://[BUCKET_NAME]/[FOLDER_NAME]\",\n \"paths\": [\n \"HelloWorld.java\",\n \"HelloWorld.class\"\n ]\n }\n }\n }\n\n### Using wildcard characters to upload more than one artifact\n\nWhen uploading multiple artifacts, you can use\n[wildcard characters](/storage/docs/wildcards) in `paths` to specify multiple\nfiles.\n\nThe following example takes as an argument a file named `classes`, which\ncontains the names of the `.java` files to compile. It then uploads any `.class`\nfile to the specified Cloud Storage bucket: \n\n### YAML\n\n steps:\n - name: 'gcr.io/cloud-builders/javac'\n args: ['@classes']\n artifacts:\n objects:\n location: 'gs://[STORAGE_LOCATION]/'\n paths: ['*.class']\n\n### JSON\n\n {\n \"steps\": [\n {\n \"name\": \"gcr.io/cloud-builders/javac\",\n \"args\": [\n \"@classes\"\n ]\n }\n ],\n \"artifacts\": {\n \"objects\": {\n \"location\": \"gs://[STORAGE_LOCATION]/\",\n \"paths\": [\n \"*.class\"\n ]\n }\n }\n }\n\n### Using substitution variables in the bucket location\n\nYou can use [substitution\nvariables](/build/docs/configuring-builds/substitute-variable-values)\nto specify a folder within the Cloud Storage bucket. If the folder you've\nspecified doesn't exist, Cloud Build will create it for you.\n\nThe example below uploads the artifacts to a Cloud Storage path that\nincludes the name of your Google Cloud project from which the build was run\n(such as gs://mybucket/myproject/): \n\n### YAML\n\n steps:\n - name: 'gcr.io/cloud-builders/javac'\n args: ['@classes']\n artifacts:\n objects:\n location: 'gs://[BUCKET_NAME]/$PROJECT_ID'\n paths: ['helloworld.class']\n\n### JSON\n\n {\n \"steps\": [\n {\n \"name\": \"gcr.io/cloud-builders/javac\",\n \"args\": [\n \"@classes\"\n ]\n }\n ],\n \"artifacts\": {\n \"objects\": {\n \"location\": \"gs://[BUCKET_NAME]/$PROJECT_ID\",\n \"paths\": [\n \"helloworld.class\"\n ]\n }\n }\n }\n\nWhat's next\n-----------\n\n- Learn how to [build `Go` projects](/build/docs/building/build-go).\n- Learn how to start a build [manually](/build/docs/running-builds/start-build-manually) and [using triggers](/build/docs/running-builds/automate-builds).\n- Learn how to [troubleshoot build errors](/build/docs/troubleshooting)."]]