A sample project showing a version controlled google form, its deployment and triggers creation.
NOTE: DUE TO LIMITATION WITH GOOGLE FORM APIS, THE TRIGGER CREATION PROCESS INCLUDE MANUAL INTERVENTION
Update .clasp.json
settings file.
clasp setting
clasp setting projectId <project-id>
- Run
clasp open
- Inside browser Click Resources -> Cloud Platform Project
- Copy project id. eg
project-id-xxx
clasp login
clasp push
clasp deploy
Execute your function (manual ):
clasp open
Now, Select function -> Run (, and debug)
clasp run <function name>
Remotely executes an Apps Script function.
To use this command you must:
-
Log in with your credentials (
clasp login --creds creds.json
) -
Deploy the Script as an API executable (Easiest done via GUI at the moment).
-
Enable any APIs that are used by the script.
-
Have the following in your appsscript.json:
"executionApi": { "access": "ANYONE" }
Currently triggers are unsupported. So, if your function is using them, it'll not execute.
- Issue detail
- Read more on Limitations.
This is required to use clasp run
command.
clasp apis enable script
Check enabled apis list
clasp apis --open
You may want to enable following two apis as well:
- script - Manages and executes Google Apps Script projects.
- serviceusage - Enables services that service consumers want to use on Google Cloud Platform, lists the available or enabled services, or disables services that service consumers no longer use.
- stackdriver - Provides users with programmatic access to Stackdriver endpoints that allow putting VM instances and other resources into maintenance mode.
clasp open --creds
- In browser click Create Credentials -> Select OAuth client Id > Check Application type: other -> Enter name > click create
- Download credentials and rename it "creds.json"
Remove old session
creds logout
Create new session:
creds login --creds creds.json
Move generated .clasprc.json
file to ~/.clasprc.json
as version v2.0.1
read only from home directory.
mv ./.clasprc.json ~/.clasprc.json
Now, execute
clasp push
Execute a function:
clasp run 'HelloWorld'
Prints out most recent the StackDriver logs. These are logs from console.log
, not Logger.log
.
- --json: Output logs in json format.
- --open: Open StackDriver logs in a browser.
- --setup: Setup StackDriver logs.
- --watch: Retrieves the newest logs every 5 seconds.
clasp logs
ERROR Sat Apr 07 2019 10:58:31 GMT-0700 (PDT) myFunction my log error
INFO Sat Apr 07 2019 10:58:31 GMT-0700 (PDT) myFunction info message
-
useful flags
clasp logs --json clasp logs --open clasp logs --watch
- Troubleshooting setup : google/clasp#506