How to find the DeploymentID from an app script deployed as an API?

887 views
Skip to first unread message

Gernot Hassenpflug

unread,
Jun 18, 2022, 1:20:09 PM6/18/22
to Google Apps Script Community
Hello all,
I have an App script deployed as an API, with various deployments, called from ruby code.
Every so often an incorrect/older deployment is mistakenly used.
I'd like to output logging information by app script itself directly in the return object to the calling ruby code about the script, most importantly the deployment ID. However, I cannot seem to find out how.
To get the script ID is straightforward:
ScriptApp.getScriptId();
For deployment IDs, there seems only to be the project.deployments.list method to list all available deployments of a given script ID, but not the particular one in use.
Any help appreciated.
(For the time being I am manually updating a version number in the app script for each deployment, which again is error prone)

Clark Lind

unread,
Jun 19, 2022, 8:42:40 AM6/19/22
to Google Apps Script Community
The best method I have found is to archive all older versions, or versions not in use. I try to archive every version except the version in use. Any archived version can be redeployed. 
Once you have just the active version/deployment, when you run   project.deployments.list, only a single deployment will be returned instead of all of them.

Gernot Hassenpflug

unread,
Jun 19, 2022, 11:35:55 AM6/19/22
to Google Apps Script Community
On Sunday, June 19, 2022 at 9:42:40 PM UTC+9 cwl...@gmail.com wrote:
The best method I have found is to archive all older versions, or versions not in use. I try to archive every version except the version in use. Any archived version can be redeployed. 
Once you have just the active version/deployment, when you run   project.deployments.list, only a single deployment will be returned instead of all of them.

Hello,
Thank you, that is a very useful workaround indeed. I will give that a try, too bad it involves needing proper operational procedures, but at worst the script can alert the fact that more than one ID is currently non-archived.
Much appreciated!
Gernot Hassenpflug
Reply all
Reply to author
Forward
0 new messages