Mateus
Mateus

Reputation: 409

Firebase Functions: Know the number of the new version deployed by Firebase CLI

When I use the firebase deploy command to deploy the functions, is there any way to find out the number of this latest version deployed? (and know what the current version is)?

Because to find this information on the web console (one by one) by entering each function, load the dashboard ... it consumes lots of time.

The reason for this question is: I deployed some functions yesterday. Another person uploaded older versions of the functions (without updating their git). Result? it became a mess and stopped everything!

It took me a while to discover that they implemented old versions of other functions :-{

So it would be quite simple: When executing the command for example: firebase deploy --only functions, the terminal itself could show:

functionA> (release 1)
functionB> (release 30)

Upvotes: 2

Views: 813

Answers (2)

JM Gelilio
JM Gelilio

Reputation: 3768

@RenaudTarnec 's answer is correct. The other way that I see(not using the Firebase CLI) to get only the version number of deployed Cloud Function is adding K_REVISION environment variable in your code. The K_REVISION key is the version identifier of the function. This is the example on nodejs:

exports.helloWorld = (req, res) => {
  const version = process.env.K_REVISION ;
  console.log(`Running version ${version}`);
  res.status(200).send(`Running version ${version}\n`)
};

when using curl it shows like this:

$ curl https://us-central1-projectname.cloudfunctions.net/helloWorld
Running version 5

The output returned five because I deployed this the function five times.

Upvotes: 4

Renaud Tarnec
Renaud Tarnec

Reputation: 83103

Preamble: This solution is not through the CLI. AFAIK it is not possible, through the CLI, to get the version of a deployed Cloud Function

You can find the deployed version on the Google Cloud Console, see below:

enter image description here

Do as follows:

  1. Go to https://console.cloud.google.com/functions
  2. (If necessary, switch to the desired project)
  3. Open the "Function details" screen by clicking on the Function name

In the drop-down box you can see the Version number.

Upvotes: 2

Related Questions