Rollback your Google Cloud Function to its previous version

Photo by on Unsplash
PROJECT_NUM=$(gcloud projects describe $PROJECT_ID \
VERSION_NUM=$(gcloud functions describe --project=leoy-toolbox \
$FUNCTION_NAME --format="value(version_id)")
BUILD_NUM=$(gcloud functions describe --project=leoy-toolbox \
$FUNCTION_NAME --format="value(build_id)")
LOCATION=$(gcloud functions describe --project=leoy-toolbox \
$FUNCTION_NAME --format="value(name)") | awk -F/ '{ print $4 }')
SOURCE=$(gsutil --p=$PROJECT_ID ls \
| grep -v "version-$VERSION_NUM" | tail -1)
gcloud functions deploy --project=$PROJECT_ID $FUNCTION_NAME \
--source=$SOURCE/ \



A collection of technical articles and blogs published or curated by Google Cloud Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store

DevRel Engineer in Google Cloud, specializing in Observability and Reliability. I try to whisper to horses in free time.