Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
onlinelaser opened this Issue Mar 12, 2018 · 30 comments

Comments

Projects
None yet
@onlinelaser
Copy link

onlinelaser commented Mar 12, 2018

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 #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.

@grant

This comment has been minimized.

Copy link
Member

grant commented Mar 23, 2018

I think you want to redeploy to update a deployment:
clasp redeploy <deploymentId> <version> <description>
Is that right?

I think I forgot to add it in the "How To..." section. LMK if that works.

@grant grant closed this Apr 6, 2018

@andysumi

This comment has been minimized.

Copy link

andysumi commented Apr 9, 2018

@grant
I am experiencing the same phenomenon.
Can note update version of Web App with "clasp deploy".

@grant

This comment has been minimized.

Copy link
Member

grant commented Apr 9, 2018

@andysumi What are the commands you're using? Use redeploy to update, deploy to create.

@andysumi

This comment has been minimized.

Copy link

andysumi commented Apr 9, 2018

@grant
I used both command, but it did not work as expected.

$ clasp version deploy-from-clasp
Created version 4.
$ clasp deploy 4 deploy-from-clasp
- [deploymentId] @4.
$ clasp open
Opening script: [scriptId]

===> I expected version of WebApp it was updated to "4", but it was not updated(it remained "3").

$ clasp redeploy [deploymentId] 4 deploy-from-clasp-again
Updated deployment.
$ clasp open
Opening script: [scriptId]

===> Again, the version of WebApp was not updated.
@jhairau

This comment has been minimized.

Copy link

jhairau commented Apr 17, 2018

@grant @andysumi @onlinelaser
I've also used both commands.

True: There is a new version deployed on the Google Apps Scripts
False: There is NOT a new Web App version deployed on Google Apps Scripts

@grant grant reopened this Apr 17, 2018

@grant

This comment has been minimized.

Copy link
Member

grant commented Apr 17, 2018

This may be an issue with the API. I'll have to look further.

@onlinelaser

This comment has been minimized.

Copy link
Author

onlinelaser commented Apr 23, 2018

@grant sorry for the delay, finally got back to testing this, and I can also confirm that neither deploy nor deploy followed immediately by a redeploy make the new deployment active 😞

@pablodonayre

This comment has been minimized.

Copy link

pablodonayre commented Apr 24, 2018

When i use: clasp redeploy <id of deployment> <version> <description>
I get "Updated deployment" in my terminal

But, 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?

@Ryangr0

This comment has been minimized.

Copy link

Ryangr0 commented Apr 25, 2018

We have the same problem.

@iaindooley

This comment has been minimized.

Copy link

iaindooley commented May 20, 2018

It doesn't appear that clasp deploy can be used to update a web application, and also can't be used to approve permissions and things like that. This would be a very useful addition. At the moment, the "Deploy as Web Application" is the only step in the development process that requires a desktop browser.

@grant

This comment has been minimized.

Copy link
Member

grant commented May 31, 2018

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:

  "webapp": {
    "access": "MYSELF",
    "executeAs": "USER_DEPLOYING"
  }

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

  1. clasp create
  2. clasp open
  3. View > Show manifest file
  4. Observe the manifest is updated
{
  "timeZone": "America/New_York",
  "dependencies": {
  },
  "webapp": {
    "access": "MYSELF",
    "executeAs": "USER_DEPLOYING"
  },
  "exceptionLogging": "STACKDRIVER"
}

Setup other web app files

index.html

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    hi
  </body>
</html>

test.gs

function doGet() {
    return HtmlService
      .createTemplateFromFile('index')
      .evaluate();
}
  1. clasp push
  2. clasp deploy
    1. Copy the long id
  3. Go to the URL, it should be something like this:
    https://script.google.com/a/{DOMAIN}/macros/s/{VERSION_ID}/exec
  4. See the successful deployment of a web app.

Follow-up

Good news (if this is correct): clasp isn't doing anything wrong.
Bad news: It's really not obvious why creating a web app with clasp fails.

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 clasp project.

We should at least give README tips on how to start with creating the 3 types of scripts to prevent this error.

@campionfellin

This comment has been minimized.

Copy link
Collaborator

campionfellin commented May 31, 2018

Is it possible, and/or a good idea to have some sort of flag for clasp deploy like --type (web|api) that adds that to the appsscript.json for the user?

@grant

This comment has been minimized.

Copy link
Member

grant commented May 31, 2018

I don't think adding more CLI flags to clasp will help. clasp should work out of the box. A type should really be for create.

clasp create
What type of project do you want to create?
x Standalone
- Add-on
- Web App

# Advanced way
clasp create --type standalone
clasp create --type addon --docs
clasp create --type webapp

What we really need is more of the following:

  • Warn when clasp push would override files. This is probably what happened here with the appsscript.json being overwritten.
  • Improve clasp create to provide options for creating an add-on, executable, or web app. See above.
  • Improve the process of creating a manifest. It would be great if there was autocompletion support. This is like package.json for Node modules.
@shai

This comment has been minimized.

Copy link

shai commented Jun 24, 2018

@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.

@TrojanCoder

This comment has been minimized.

Copy link

TrojanCoder commented Jun 24, 2018

@shai If I'm reading this ticket correctly you should be able to do everything without the WEB UI, it's just not super clear because you'll need to manually update your appscript.json file. Here are the valid options:

"webapp": {
    "access": "MYSELF",
    "access": "ANYONE",
    "executeAs": "USER_DEPLOYING"
    "executeAs": "USER_ACCESSING"
    "executeAs": "ANYONE_ANONYMOUS"
  },

You need to pick one of the "acces" types and one of the "executeAs" types. Note that "ANYONE_ANONYMOUS" can only be used with "executeAs" type "USER_DEPLOYING"

@shai

This comment has been minimized.

Copy link

shai commented Jun 24, 2018

@TrojanCoder I've actually got this already:

  "webapp": {
    "access": "ANYONE_ANONYMOUS",
    "executeAs": "USER_DEPLOYING"
  },

and when I clasp deploy it says that it deployed a new version but when I go to publish -> deploy as web app ; I see that it's using the old version. Also, when I go and test the code, I see that I'm not getting the updated expected console logs of the newer version.

@grant

This comment has been minimized.

Copy link
Member

grant commented Jun 27, 2018

I just tested the steps I wrote above again. Deploying a web app from clasp works. You just need to make sure you update the appsscript.json, clasp push, and clasp deploy.

Steps: #63 (comment)

Set up and deploy a web app

clasp clone 1kDaDgJUTxkVmr7TkPSqx2wjxMhiY3DH1v_nZfpdkdsPcy2Lfo-09onYz
Cloned 2 files.
└─ appsscript.json
└─ Code.js
vi appsscript.json # add the `access` and `executeAs` fields.
vi index.html # write an HTML skeleton with "hi"
vi Code.js

clasp push
└─ Code.js
└─ appsscript.json
└─ index.html
Pushed 3 files.

clasp deploy
Created version 1.
- AKfycbwP6WvBwvNI3m_d3Ts8bnYBX8y0lG7OQEuV65m2E6t3J44g9Cay8wGZ2JRfQ9mHcpI1 @1.

Go to
https://script.google.com/a/{YOUR_DOMAIN}/macros/s/AKfycbwP6WvBwvNI3m_d3Ts8bnYBX8y0lG7OQEuV65m2E6t3J44g9Cay8wGZ2JRfQ9mHcpI1/exec

See the page: "hi"

Deploy Again

vi index.html # write an HTML skeleton with "hi 2"
clasp push
clasp version
clasp deploy 2

Go to the new URL.
See the page: "hi2"


I haven't tested redeploy, but deploying a web app multiple times should work.

@onlinelaser

This comment has been minimized.

Copy link
Author

onlinelaser commented Jun 28, 2018

So I've just tested that workflow and it does push the deployment up (which was working originally as well) - but it also doesn't make it active as the published project version.

Meaning that you still need to go to the UI and make the project version the one you just deployed :-(

@shai

This comment has been minimized.

Copy link

shai commented Jul 1, 2018

so I'm unsure about why it's working for some and not others? @grant if you last comment you said and showed that it works, but @onlinelaser and myself say it isn't and then you added the API support needed label which implies it doesn't work?

Should I keep trying to get it working or did you verify that it isn't working and we need to wait for a solution?

@grant

This comment has been minimized.

Copy link
Member

grant commented Jul 1, 2018

So I've just tested that workflow and it does push the deployment up (which was working originally as well) - but it also doesn't make it active as the published project version.

Meaning that you still need to go to the UI and make the project version the one you just deployed :-(

I added the API support label because it looks like the UI does something different the API cannot do yet.

@lgordey

This comment has been minimized.

Copy link

lgordey commented Aug 10, 2018

Any news here?

I created an issue #286 about deploy, seems to be a duplicate

@satetsu888

This comment has been minimized.

Copy link

satetsu888 commented Aug 14, 2018

I found out the way to update the published web app endpoint by clasp.

We should use redeploy to update exists application ( I think we expect it is "deploy" and confusing ).

The function clasp deploy wraps create deployments API, and it always create new endpoints.
https://developers.google.com/apps-script/api/reference/rest/v1/projects.deployments/create

We just need

  • setup appsscript.json
  • clasp deploy only first time
  • clasp version and crasp redeploy to update like #63 (comment)
@RomainVialard

This comment has been minimized.

Copy link

RomainVialard commented Sep 27, 2018

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.

@grant grant added this to the Requires API Changes milestone Oct 29, 2018

@freddy-daniel

This comment has been minimized.

Copy link

freddy-daniel commented Jan 15, 2019

I think you want to redeploy to update a deployment:
clasp redeploy <deploymentId> <version> <description>
Is that right?

I think I forgot to add it in the "How To..." section. LMK if that works.

C:\Users\Freddy\Desktop\gmail add-on  (meeting-assistant@1.0.0)
λ clasp redeploy AKfycbzwBPYA5QYbALsLecxp5_OuOxCrbBKzs78D8XDs9m3kDg2DSvCG-fyNG82ssSoOSDM7gg 1 Test
🤔  Unknown command "clasp redeploy"

Forgot clasp commands? Get help:
  clasp --help
@grant

This comment has been minimized.

Copy link
Member

grant commented Jan 17, 2019

FYI: clasp redeploy has been removed in favor of clasp deploy with -- arguments.

@rheajt

This comment has been minimized.

Copy link

rheajt commented Jan 22, 2019

The confusion that I ran into was getting the correct deploymentId to use with clasp deploy.

You need to got to "Publish > Deploy from Manifest" and Get ID of the deployment you want to use.

Then use clasp deploy -i <<ID from the manifest>>

@zffocussss

This comment has been minimized.

Copy link

zffocussss commented Feb 26, 2019

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.

how do I deloy programmatically?

@zffocussss

This comment has been minimized.

Copy link

zffocussss commented Feb 26, 2019

I just tested the steps I wrote above again. Deploying a web app from clasp works. You just need to make sure you update the appsscript.json, clasp push, and clasp deploy.

Steps: #63 (comment)

Set up and deploy a web app

clasp clone 1kDaDgJUTxkVmr7TkPSqx2wjxMhiY3DH1v_nZfpdkdsPcy2Lfo-09onYz
Cloned 2 files.
└─ appsscript.json
└─ Code.js
vi appsscript.json # add the `access` and `executeAs` fields.
vi index.html # write an HTML skeleton with "hi"
vi Code.js

clasp push
└─ Code.js
└─ appsscript.json
└─ index.html
Pushed 3 files.

clasp deploy
Created version 1.
- AKfycbwP6WvBwvNI3m_d3Ts8bnYBX8y0lG7OQEuV65m2E6t3J44g9Cay8wGZ2JRfQ9mHcpI1 @1.

Go to
https://script.google.com/a/{YOUR_DOMAIN}/macros/s/AKfycbwP6WvBwvNI3m_d3Ts8bnYBX8y0lG7OQEuV65m2E6t3J44g9Cay8wGZ2JRfQ9mHcpI1/exec

See the page: "hi"

Deploy Again

vi index.html # write an HTML skeleton with "hi 2"
clasp push
clasp version
clasp deploy 2

Go to the new URL.
See the page: "hi2"

I haven't tested redeploy, but deploying a web app multiple times should work.

what is difference between deploy and publish?
I just use clasp deploy.but How can I publish this new version to chrome web store?

@darul75

This comment has been minimized.

Copy link

darul75 commented Mar 1, 2019

hello, what about a google sheets addon, is the deploy option updating a published version?

@zffocussss

This comment has been minimized.

Copy link

zffocussss commented Mar 4, 2019

hello, what about a google sheets addon, is the deploy option updating a published version?

I think there is no difference between sheet and doc.clasp deploy will create a new version number and deploymentId,but you must choose the deplomentID and publish manually

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.