Reputation: 1678
I created a web app for my google sheet script. I deployed it with version 1 and and it works
Now I want to make on going changes and deploy my changes, Do I need to increase the version for each change I deploy? or can I update on current version?
Also, is there a way to get the current version programmaticaly?
Upvotes: 5
Views: 3842
Reputation: 4844
Click "Manage deployments"
Under Configuration click the edit pencil
Upvotes: 5
Reputation: 201378
For your situation, I would like to introduce because I had a workaround that I also use.
In generally, when the script of Web Apps was updated, the project version is required to be increased and Web Apps is redeployed with the new version.
But if you want to deploy Web Apps without increasing the version, as a workaround, you can achieve it by using a library. The flow of for this workaround is as follows.
function doGet(e) {return lib.main(e)}
function main(e) {return yourfunction(e)}
yourfunction(e)
is the function in the project that you are using.In this workaround, when you want to modify the script, please modify the library project. By this, when the library is updated, the project which deployed Web Apps is automatically updated because "Development mode" is turned on when the library is installed. This update is also reflected to Web Apps. So the script of Web Apps can be updated without increasing the version.
As a sample, the scripts for both project after making the settings described above are as follows:
function doGet(e) {
return lib.main(e);
}
function main(e) {
return yourfunction(e);
}
function yourfunction(e) {
do something: The script which is run when users accessed to Web Apps.
return something
}
In order to retrieve the current version of the project, you can use Apps Script API. This is also answered by tehhowch. In a recent update, users got to be able to retrieve and create the project versions. By using this, you can achieve this. The required scope is https://www.googleapis.com/auth/script.projects
or https://www.googleapis.com/auth/script.projects.readonly
.
GET https://script.googleapis.com/v1/projects/### scriptId ###/versions
If you want to create the new version using script, you can use the following endpont.
POST https://script.googleapis.com/v1/projects/### scriptId ###/versions
Request body is
{
"versionNumber": 3,
"description": "sample description"
}
If this was not useful for you, I'm sorry.
Upvotes: 6
Reputation: 9872
When creating a web app for apps script, two links are given:
exec
will only load the specified published version of the code.dev
will load the latest saved code (allowing for testing of code prior to making a new version).Programmatic control of the deployed version is available via the Apps Script API, and to a Dev environment via clasp
.
Upvotes: 1
Reputation: 2798
You need to increase the version for each change, unless you use the "dev" version of the app when it will always display the latest version. This will only be visible when you are logged into your account though.
Upvotes: 0