gcloud alpha functions local deploy

NAME
gcloud alpha functions local deploy - deploy a Google Cloud Function locally
SYNOPSIS
gcloud alpha functions local deployNAME[--builder=BUILDER][--entry-point=ENTRY_POINT][--ignore-file=IGNORE_FILE][--port=PORT; default=8080][--runtime=RUNTIME][--source=SOURCE][--build-env-vars-file=FILE_PATH    |--clear-build-env-vars    |--set-build-env-vars=[KEY=VALUE,…]    |--remove-build-env-vars=[KEY,…]--update-build-env-vars=[KEY=VALUE,…]][--clear-env-vars    |--env-vars-file=FILE_PATH    |--set-env-vars=[KEY=VALUE,…]    |--remove-env-vars=[KEY,…]--update-env-vars=[KEY=VALUE,…]][GCLOUD_WIDE_FLAG]
DESCRIPTION
(ALPHA)gcloud alpha functions local deploy Deploy aGoogle Cloud Function locally.
POSITIONAL ARGUMENTS
NAME
Name of the locally deployed Google Cloud function.
FLAGS
--builder=BUILDER
Name of the builder to use for pack, e.g.gcr.io/serverless-runtimes/google-22-full/builder/go.
--entry-point=ENTRY_POINT
Name of a Google Cloud Function (as defined in source code) that will beexecuted. Defaults to the resource name suffix (ID of the function), if notspecified.
--ignore-file=IGNORE_FILE
Override the .gcloudignore file in the source directory and use the specifiedfile instead. By default, the source directory is your current directory. Notethat it could be changed by the --source flag, in which case your .gcloudignorefile will be searched in the overridden directory. For example,--ignore-file=.mygcloudignore combined with--source=./mydir would point to./mydir/.mygcloudignore
--port=PORT; default=8080
Port for the deployment to run on. The default port is 8080 for new localdeployments.
--runtime=RUNTIME
Runtime in which to run the function.

Required when deploying a new function; optional when updating an existingfunction.

For a list of available runtimes, rungcloud functions runtimeslist.

--source=SOURCE
Location of source code to deploy.

Location of the source can be one of the following three options:

  • Source code in Google Cloud Storage (must be a.zip archive),
  • Reference to source repository or,
  • Local filesystem path (root directory of function source).

Note that, depending on your runtime type, Cloud Functions will look for fileswith specific names for deployable functions. For Node.js, these filenames areindex.js orfunction.js. For Python, this ismain.py.

If you do not specify the--source flag:

  • The current directory will be used for new function deployments.
  • If the function was previously deployed using a local filesystem path, then thefunction's source code will be updated using the current directory.
  • If the function was previously deployed using a Google Cloud Storage location ora source repository, then the function's source code will not be updated.

The value of the flag will be interpreted as a Cloud Storage location, if itstarts withgs://.

The value will be interpreted as a reference to a source repository, if itstarts withhttps://.

Otherwise, it will be interpreted as the local filesystem path. When deployingsource from the local filesystem, this command skips files specified in the.gcloudignore file (seegcloud topicgcloudignore for more information). If the.gcloudignorefile doesn't exist, the command will try to create it.

The minimal source repository URL is:https://source.developers.google.com/projects/${PROJECT}/repos/${REPO}

By using the URL above, sources from the root directory of the repository on therevision taggedmaster will be used.

If you want to deploy from a revision different frommaster, appendone of the following three sources to the URL:

  • /revisions/${REVISION},
  • /moveable-aliases/${MOVEABLE_ALIAS},
  • /fixed-aliases/${FIXED_ALIAS}.

If you'd like to deploy sources from a directory different from the root, youmust specify a revision, a moveable alias, or a fixed alias, as above, andappend/paths/${PATH_TO_SOURCES_DIRECTORY} to the URL.

Overall, the URL should match the following regular expression:

^https://source\.developers\.google\.com/projects/(?<accountId>[^/]+)/repos/(?<repoName>[^/]+)(((/revisions/(?<commit>[^/]+))|(/moveable-aliases/(?<branch>[^/]+))|(/fixed-aliases/(?<tag>[^/]+)))(/paths/(?<path>.*))?)?$

An example of a validly formatted source repository URL is:

https://source.developers.google.com/projects/123456789/repos/testrepo/moveable-aliases/alternate-branch/paths/path-to=source
At most one of these can be specified:
--build-env-vars-file=FILE_PATH
Path to a local YAML file with definitions for all build environment variables.All existing build environment variables will be removed before the new buildenvironment variables are added.
--clear-build-env-vars
Remove all build environment variables.
--set-build-env-vars=[KEY=VALUE,…]
List of key-value pairs to set as build environment variables. All existingbuild environment variables will be removed first.
Only --update-build-env-vars and --remove-build-env-vars can be used together.If both are specified, --remove-build-env-vars will be applied first.
--remove-build-env-vars=[KEY,…]
List of build environment variables to be removed.
--update-build-env-vars=[KEY=VALUE,…]
List of key-value pairs to set as build environment variables.
At most one of these can be specified:
--clear-env-vars
Remove all environment variables.
--env-vars-file=FILE_PATH
Path to a local YAML file with definitions for all environment variables. Allexisting environment variables will be removed before the new environmentvariables are added.
--set-env-vars=[KEY=VALUE,…]
List of key-value pairs to set as environment variables. All existingenvironment variables will be removed first.
Only --update-env-vars and --remove-env-vars can be used together. If both arespecified, --remove-env-vars will be applied first.
--remove-env-vars=[KEY,…]
List of environment variables to be removed.
--update-env-vars=[KEY=VALUE,…]
List of key-value pairs to set as environment variables.
GCLOUD WIDE FLAGS
These flags are available to all commands:--access-token-file,--account,--billing-project,--configuration,--flags-file,--flatten,--format,--help,--impersonate-service-account,--log-http,--project,--quiet,--trace-token,--user-output-enabled,--verbosity.

Run$gcloud help for details.

NOTES
This command is currently in alpha and might change without notice. If thiscommand fails with API permission errors despite specifying the correct project,you might be trying to access an API with an invitation-only early accessallowlist.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-22 UTC.