GCBL runs Google Cloud Build locally, allowing easier debugging, execution of builds on your own hardware, and integration into local build and test workflows. Please note that the Local Builder is not 100% feature-compatible with the hosted Google Cloud Build service.
This Google Cloud Build Local fork is maintained by volunteers, which at best, makes this ok for a local debugging tool for Google Cloud Build. It does not support 100% feature parity with the hosted Cloud Build service and should not be used for production workloads.
As of 2023, the original repository from Google has been archived. This fork is an attempt to keep the project alive, at least, in some form close to the original, and maybe improve on it a bit.
- Added support for loading
.env
file secrets forsecretEnv
replacements.
This will convert only the matchingsecretEnv
into a correspondingenv
with a value.
To use this, just add the--env=<envfilepath>
argument withenvfilepath
as the path to the.env
file.
This is not supported in the cloud, and only works for GCBL. Which means the cloud will simply treat a secretEnv as intended :) - No contributor agreements. Just code!
- Added support for skipping cloud token gathering and metadata with argument
--no-cloud
. This let's you run cloud-build-local without an activegcloud
authentication token (which requires a GCP account).
To run a local build you should make sure you've got credentials to GCP if using any resources (gcloud auth login
),
then specify a false
dryrun, the config, and the source code/content directory path.
./cloud-build-local --dryrun=false --config=path/to/cloudbuild.yaml --env=/path/to/.env path/to/code
To build and test the GCPL, you need a working Go environment. You should also install gcloud and Docker.
This binary has only been tested to work on Linux operating systems.
go mod vendor
go get
go build -o cloud-build-local github.com/GoogleCloudPlatform/cloud-build-local
Optionally, create a system-wide link to the built executable:
sudo ln -s "$(pwd)/cloud-build-local" /usr/bin/cloud-build-local
If you'd like to run the manual test build...
- Create a
tests/.env
file with a secret replacement value:HELLO_BUILD=my secret env variable replacement
- Run the test locally:
./cloud-build-local --dryrun=false --config=./tests/cloudbuild.yaml --env=./tests/.env ./tests/src
Other tests (legacy):
go test $(go list github.com/GoogleCloudPlatform/cloud-build-local/... | grep -v vendor)