question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clasp deploy doesn't update the deployed version with Google Apps Script Web App

See original GitHub issue

Expected Behavior

Perhaps I’m misunderstanding, but from the readme I’d thought that clasp deploy would allow me to publish a new version of a Web App (in this case bound to a google sheet).

I’d expected the workflow to be as follows:

  1. clasp version “My new version”

Created version xx.

  1. clasp deploy xx

yyyyyyyyyyyyyyyyy @xx

  1. clasp open browser opens to newly published version “xx”

Actual Behaviour

The version is created as expected, but the web app Project Version remains at the last deployed version not the version used with clasp deploy. To actually deploy it I have to go into the Script Editor then Publish > Deploy as Web App and then select the version “xx”

Related Issues

This seems related to https://github.com/google/clasp/issues/43, however that issue specifically relates to Chrome store apps and this is a Web App which the comments on that issue suggest should be supported.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:12
  • Comments:39 (9 by maintainers)

github_iconTop GitHub Comments

11reactions
sovcikcommented, Mar 25, 2020

Summarizing:

  1. There is a difference between version and deployment. A version is similar to a git tag, while a deployment is actual code available for execution and accessible at https://script.google.com/macros/s/{deploymentID}/exec
  2. list of available deployments can be obtained by running clasp deployments
  3. there is always only one published deployment which is available for end-users. The published deployment is is flagged as web app meta-version in the list of deployments.
  4. clasp deploy creates new deployment if no deploymentId is specified and creates new version if no version is specified
  5. new deployments are useful for testing before making them default (using link mentioned in point 1)
  6. in order to make version available for end-users you have to publish it by deploying it into published deployment by running
    clasp --deploymentId {published_deployment_id} --version {selected_version_here}

So the process:

  1. use clasp deployments and
    1. select one deployment you will use for testing => test_deployment_id
    2. get published deployment (one having web app meta-version flag) => pub_deployment_id
  2. modify your code
  3. clasp push
  4. clasp deploy --deploymentId $test_deployment_id creates version => new_version
  5. test your version at
    https://script.google.com/macros/s/{test_deployment_id}/exec
  6. if satisfied, deploy your version into published deployment
    clasp deploy --deploymentId $pub_deployment_id --versionNumber $new_version

So, in the end it looks that clasp deploy works as designed. What’s missing is the documentation 😃

6reactions
NicolaSpreaficocommented, Dec 6, 2019

I found this trick working for deploy a new version of webapp.

clasp deployments

  • Select the version (if exists ) where there is web app meta-version attribute
  • I attribute is not found, use the last deployment id
LAST_DEPLOYMENT_ID=$( clasp deployments | pcregrep -o1 '\- ([A-Za-z0-9\-\_]+) @\d+ - web app meta-version' )
	if [ -z "$LAST_DEPLOYMENT_ID" ]
	then
		LAST_DEPLOYMENT_ID=$( clasp deployments | tail -1 | pcregrep -o1 '\- ([A-Za-z0-9\-\_]+)' ) 
	fi

After selecting deploment ID, proceed with

clasp deploy --deploymentId $LAST_DEPLOYMENT_ID

I found that web app meta-version attribute only appaers when web-app application is update from AppsScript code editor, so we need to consider the deploymentIDs order to get the proper version. Also the webapp should remain published to last existing version or the “select last row” trick will not work.

I tried a couple of times and seems to work, you can try and test as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't deploy new version of published Google apps script app ...
The deployment is a published/approved apps script project. So far I have worked around the problem by updating version manually in the GUI....
Read more >
Command Line Interface using clasp | Apps Script
To deploy a project with clasp , first create an immutable version of the Apps Script project.
Read more >
Google Sheets Web App Deployment Process - Apps Script V8
How to deploy, redeploy and manage Google Sheets web app in Apps Script V8 runtime?# web # app #sheets.
Read more >
ScriptApp.getService().getUrl() doesn't work for versioned ...
The workaround of replacing the ID with your script ID in the URL only works if you are on the first deployment of...
Read more >
Google Apps Script Tips to build Add-ons | Railsware Blog
Manage Deployment Versions: Create, update, and view multiple deployments of your project. Structure Code: clasp automatically converts your ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found