Comments (40)
Summarizing:
- 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
- list of available deployments can be obtained by running
clasp deployments
- 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. clasp deploy
creates new deployment if no deploymentId is specified and creates new version if no version is specified- new deployments are useful for testing before making them default (using link mentioned in point 1)
- 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:
- use
clasp deployments
and- select one deployment you will use for testing => test_deployment_id
- get published deployment (one having web app meta-version flag) => pub_deployment_id
- modify your code
clasp push
clasp deploy --deploymentId $test_deployment_id
creates version => new_version- test your version at
https://script.google.com/macros/s/{test_deployment_id}/exec
- 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 :-)
from 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
:
"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
clasp create
clasp open
- View > Show manifest file
- 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();
}
clasp push
clasp deploy
- Copy the long id
- Go to the URL, it should be something like this:
https://script.google.com/a/{DOMAIN}/macros/s/{VERSION_ID}/exec
- 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.
from clasp.
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?
from clasp.
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.
from clasp.
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 theappsscript.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.
from clasp.
It seems that clasp deploy a new deployment ID when not specified deployment ID with -i
parameter.
So if your just updating a web app using latest code, just get url from apps script website
which like this https://script.google.com/macros/s/{deploymentID}/exec
and specify -i
parameter with deploymentID when new code deploy
example command: clasp push && clasp deploy -i deploymentID
from clasp.
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?
from clasp.
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.
from clasp.
FYI: clasp redeploy
has been removed in favor of clasp deploy
with --
arguments.
from clasp.
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?
from clasp.
@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.
from clasp.
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 timeclasp version
andcrasp redeploy
to update like #63 (comment)
from clasp.
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.
from clasp.
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 ([email protected])
Ξ» clasp redeploy AKfycbzwBPYA5QYbALsLecxp5_OuOxCrbBKzs78D8XDs9m3kDg2DSvCG-fyNG82ssSoOSDM7gg 1 Test
π€ Unknown command "clasp redeploy"
Forgot clasp commands? Get help:
clasp --help
from clasp.
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:
{
"deploymentId": "AKfycbwGoFhpo5qekznUEn9z4Crt9BtFz0ubDsjK9sNlcJz0xTroscdU",
"deploymentConfig": {
"scriptId": "1jeLVzVdwPdBX5prcwCUeTc4nkQ8XAxFSd7QcuJJ96MB_UozF0iUMShiO",
"versionNumber": 251,
"manifestFileName": "appsscript",
"description": "web app meta-version"
},
"updateTime": "2020-06-23T08:08:57.828Z",
"entryPoints": [
{
"entryPointType": "EXECUTION_API",
"executionApi": {
"entryPointConfig": {
"access": "ANYONE"
}
}
}
]
}
Entry points after deploying from the Script Editor:
{
"deploymentId": "AKfycbwGoFhpo5qekznUEn9z4Crt9BtFz0ubDsjK9sNlcJz0xTroscdU",
"deploymentConfig": {
"scriptId": "1jeLVzVdwPdBX5prcwCUeTc4nkQ8XAxFSd7QcuJJ96MB_UozF0iUMShiO",
"versionNumber": 251,
"manifestFileName": "appsscript",
"description": "web app meta-version"
},
"updateTime": "2020-06-23T08:10:12.540Z",
"entryPoints": [
{
"entryPointType": "WEB_APP",
"webApp": {
"url": "https://script.google.com/macros/s/AKfycbwGoFhpo5qekznUEn9z4Crt9BtFz0ubDsjK9sNlcJz0xTroscdU/exec",
"entryPointConfig": {
"access": "ANYONE_ANONYMOUS",
"executeAs": "USER_DEPLOYING"
}
}
},
{
"entryPointType": "EXECUTION_API",
"executionApi": {
"entryPointConfig": {
"access": "ANYONE"
}
}
}
]
}
This is why we get a Drive Error when, after deploy from clasp, we try to enter the /dev page.
referenced here: googleapis/google-api-python-client#866
from clasp.
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.
from clasp.
@grant
I am experiencing the same phenomenon.
Can note update version of Web App with "clasp deploy".
from clasp.
@andysumi What are the commands you're using? Use redeploy
to update, deploy
to create.
from clasp.
@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.
from clasp.
@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
from clasp.
This may be an issue with the API. I'll have to look further.
from clasp.
@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 π
from clasp.
We have the same problem.
from clasp.
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.
from clasp.
@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"
from clasp.
@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.
from clasp.
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.
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.
from clasp.
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 :-(
from clasp.
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?
from clasp.
Any news here?
I created an issue #286 about deploy
, seems to be a duplicate
from clasp.
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>>
from clasp.
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?
from clasp.
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
, andclasp 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.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?
from clasp.
hello, what about a google sheets addon, is the deploy option updating a published version?
from clasp.
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
from clasp.
https://script.google.com/macros/s/{test_deployment_id}/exec
When I deploy my test_deployment_id and tries to open it on the browser, it redirects to
https://script.google.com/a/macros/safewebmed.com.br/s/{test_deployment_id}/exec
and shows an error page:
Sorry, unable to open the file at this time.
Please check the address and try again.
Get stuff done with Google Drive
Apps in Google Drive make it easy to create, store and share online documents, spreadsheets, presentations and more.
Learn more at drive.google.com/start/apps.
from clasp.
regarding @sovcik Summarizing
in item 6 of first ordered list
- 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}
sub-command deploy
is occasionally omitted after clasp
, Presumably:
clasp deploy --deploymentId {published_deployment_id} --version {selected_version_here}
from clasp.
- test your version at
https://script.google.com/macros/s/{test_deployment_id}/exec
after doing that step, the browser autoredirects to https://script.google.com/a/macros/mydomain.com/s/{test_deployment_id}/exec
and the page shows this error:
Sorry, unable to open the file at this time.
Please check the address and try again.
Would really like to get this working.
from clasp.
https://script.google.com/macros/s/{test_deployment_id}/exec
When I deploy my test_deployment_id and tries to open it on the browser, it redirects to https://script.google.com/a/macros/safewebmed.com.br/s/{test_deployment_id}/exec and shows an error page: Sorry, unable to open the file at this time.
Please check the address and try again.
Get stuff done with Google Drive
Apps in Google Drive make it easy to create, store and share online documents, spreadsheets, presentations and more.
Learn more at drive.google.com/start/apps.
I started using Clasp today and can confirm this issue still persists (following same steps) to this day. Any workaround available for this?
from clasp.
somehow i found the solution for this.
The expected behavior:
- Let's say, the existing deployment id is "AKfycbwGoFhpo5qekznUEn9z4Crt9BtFz0ubDsjK9sNlcJz0xTroscdU"
- last deployed version is 25
I want to deploy the app with the same deployment ID but a new version.
when we do clasp deploy
it generates a new deployment ID and a new version, which is not the expected behavior, as we don't want a new deployment ID.
The right way:
clasp version && clasp deploy -i AKfycbwGoFhpo5qekznUEn9z4Crt9BtFz0ubDsjK9sNlcJz0xTroscdU -V 26
clasp version
will create the next version (25 -> 26) but doesn't deploy the app.clasp deploy -i <deployment ID> -V <version number>
command is to redeploy app with same deployment ID and with the existing version, which we created usingclasp version
from clasp.
Related Issues (20)
- [FR] please provide option to specify port for clasp login
- Facing issue when tried to do clasp login with service account HOT 1
- Does clasp support Typescript 4.2? The latest version of ts2gas supports Typescript 4.2
- Feature request : set / get the GCP Project of the Script HOT 3
- .claspignore is not ignoring anything in it HOT 3
- 'clasp login' doesn't wait for response
- Access blocked: authorisation error when running clasp login
- Clasp claims it has pushed files even when Apps Script API is not enabled
- Clasp project dead ? HOT 3
- IMPORTANT: Clasp login may fail for new users HOT 2
- Clasp pull does not empty the local project folder before pulling
- Console log - incorrect time zone
- clasp push hangs if .claspignore file is present HOT 1
- A silent failure occurs if a file path listed in `filePushOrder` does not exist HOT 2
- TypeError: Missing internal module 'internal/deps/node:stream' HOT 2
- Tests are broken (access denied to "communal testing project")
- [RFC] Multiple (private) GAS targets: remotes HOT 6
- New feature of clasp revert clone! HOT 2
- [RFC] (Re)create consistent GAS project for codebase: `remote create` (multi-developer workflow)
- Unable to stop pushing manifest file appscript.json = forced to redeploy scipt after each change-push files HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clasp.