clasp: Clasp deploy doesn't update the deployed version with Google Apps Script Web App
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:
- clasp version “My new version”
Created version xx.
- clasp deploy xx
yyyyyyyyyyyyyyyyy @xx
- 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.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 14
- Comments: 40 (9 by maintainers)
Commits related to this issue
- Add note about each deployment having a unique URL This would have helped me immensely. There seems to be a lot of confusion around redeployments, see google/clasp#63 and see the somewhat unrelated g... — committed to kalmi/clasp by kalmi 4 years ago
- Add note about each deployment having a unique URL This would have helped me immensely. There seems to be a lot of confusion around redeployments, see google/clasp#752 and see the somewhat unrelated ... — committed to kalmi/clasp by kalmi 4 years ago
Summarizing:
https://script.google.com/macros/s/{deploymentID}/execclasp deploymentsweb app meta-versionin the list of deployments.clasp deploycreates new deployment if no deploymentId is specified and creates new version if no version is specifiedclasp --deploymentId {published_deployment_id} --version {selected_version_here}So the process:
clasp deploymentsandclasp pushclasp deploy --deploymentId $test_deployment_idcreates version => new_versionhttps://script.google.com/macros/s/{test_deployment_id}/execclasp deploy --deploymentId $pub_deployment_id --versionNumber $new_versionSo, in the end it looks that
clasp deployworks as designed. What’s missing is the documentation 😃I found this trick working for deploy a new version of webapp.
clasp deploymentsweb app meta-versionattributeAfter selecting deploment ID, proceed with
I found that
web app meta-versionattribute 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.
I’m developing an API executable, and encountered a similar issue.
I can create deployments via clasp, but I can’t run these deployed API until I manually update the version via web console.
(new deployments exist, but not selected.)
Are there ways to update the published version via clasp?
It looks like the script.google.com UI updates the manifest file (
appsscript.json) file when you use the UI to publish a web app.When you use the UI to deploy a web app, it adds this bit of code to
appsscript.json:This is really important, as it’s the configuration details of the web app.
So if you are using
clasp, and expect to deploy a web app, you must manually update the manifest file.Repro
Create the project with clasp
clasp createclasp openSetup other web app files
index.htmltest.gsclasp pushclasp deployhttps://script.google.com/a/{DOMAIN}/macros/s/{VERSION_ID}/execFollow-up
Good news (if this is correct):
claspisn’t doing anything wrong. Bad news: It’s really not obvious why creating a web app withclaspfails.I think a good solution would be to enhance the setup experience around starting a new add-on/web app/script. Some ideas were thrown around in #76, but it seemed out of scope for the
claspproject.We should at least give README tips on how to start with creating the 3 types of scripts to prevent this error.
It seems that clasp deploy a new deployment ID when not specified deployment ID with
-iparameter. So if your just updating a web app using latest code, just get url from apps script website which like thishttps://script.google.com/macros/s/{deploymentID}/execand specify-iparameter with deploymentID when new code deploy example command:clasp push && clasp deploy -i deploymentIDI don’t think adding more CLI flags to clasp will help.
claspshould work out of the box. A type should really be forcreate.What we really need is more of the following:
clasp pushwould override files. This is probably what happened here with theappsscript.jsonbeing overwritten.clasp createto provide options for creating an add-on, executable, or web app. See above.package.jsonfor Node modules.FYI:
clasp redeployhas been removed in favor ofclasp deploywith--arguments.I added the
API supportlabel because it looks like the UI does something different the API cannot do yet.Is it possible, and/or a good idea to have some sort of flag for
clasp deploylike--type (web|api)that adds that to theappsscript.jsonfor the user?Apparently, when we execute clasp deploy, the command forgets to create an entry point to the webapp. See below:
Entry points after deploying from clasp:
Entry points after deploying from the Script Editor:
This is why we get a Drive Error when, after deploy from clasp, we try to enter the /dev page.
referenced here: https://github.com/googleapis/google-api-python-client/issues/866
Also note that when you manually deploy as a web app your project (using the “Deploy as web app” menu entry), it automatically generates a new deployment (or update the existing deployment if you update your web app). This specific deployment is automatically named by Apps Script “web app meta-version”, you can grab its ID and then reuse it to update this specific deployment with Clasp. This way, the UI will stay in sync, meaning you will be able to deploy either manually (using the “Deploy as web app” menu entry) or programmatically.
I found out the way to update the published web app endpoint by clasp.
We should use
redeployto update exists application ( I think we expect it is “deploy” and confusing ).The function
clasp deploywraps create deployments API, and it always create new endpoints. https://developers.google.com/apps-script/api/reference/rest/v1/projects.deployments/createWe just need
appsscript.jsonclasp deployonly first timeclasp versionandcrasp redeployto update like https://github.com/google/clasp/issues/63#issuecomment-375772312@grant can you shade some light on where we are with this issue? I would LOVE to be able to deploy a new web-app version when I push my updates. I dislike having to need to go to the WEB UI to deploy that new version of my web-app.
When i use:
clasp redeploy <id of deployment> <version> <description>I get “Updated deployment” in my terminalBut, when i refresh the web browser (F5) i get an error message “Se necesita autorización para realizar esta acción” (You need authorization to perform this action) in the browser.
Also, my previous config was: Deploy as a web app Execute the app: As me Who has access to the app: Anyone, even anonymous
How to send this two config options with a command, and how to solve my issue with the authorization?