gcloud storage cp: Upload Artifacts to GCS in CI
Copy files between the local filesystem and Cloud Storage buckets.
gcloud storage cp is the modern replacement for gsutil cp. In CI it uploads build artifacts, downloads fixtures, or syncs static sites. It supports recursive copies and parallel transfers for large trees.
Common flags
-r- copy directories recursively-n- no-clobber, skip existing destination objects--gzip-in-flight=js,css- compress matching extensions during upload- gs://BUCKET/PATH - Cloud Storage destination or source
Example in CI
Upload a build directory to a bucket prefix.
shell
gcloud storage cp -r ./dist gs://my-artifacts/builds/${GITHUB_SHA}/Common errors in CI
- storage.objects.create access ... denied - SA missing roles/storage.objectAdmin on the bucket
- The specified bucket does not exist - wrong bucket name or wrong project
- CommandException: No URLs matched - source glob did not match any local files
Key takeaways
- Copies files to and from GCS; the successor to gsutil cp.
- Use -r for directories and -n to avoid overwriting existing objects.
- Most failures are missing storage IAM roles or a wrong bucket name.
Related guides
gcloud app deploy: Deploy App Engine in CIDeploy an App Engine service from a pipeline: version and promote flags, a CI example, and the deploy errors…
gcloud compute instances list: Query VMs in CIList Compute Engine instances from a pipeline: filter and format flags, a scripting example, and the common A…
az storage blob upload: Upload to Blob in CIUpload a file to Azure Blob Storage from CI: container and auth flags, an example, and the storage errors you…