I have a Google Apps Script project, for which I have 2 deployments:
HEAD (development)
VERSION X (production)
I need to configure these 2 deployments differently (eg different filenames, usernames,...).
What is the best way of doing this? On the Project page of the G Suite Developer Hub I cannot find anything related to "deployment-specific configuration variables".
I read somewhere that you can (should?) use a PropertiesService for this, but again I cannot figure out how to (non-programmatically) edit the values for a specific deployment.
Appreciate your suggestions
Related
I am working on implementing a Google App Script project which makes use of various cloud APIs like Big Query, Cloud SQL, Google Ads etc. Implementation works pretty well through a project where GCP project ID is configured.
But I would like to have a development only version which I can use for my validation.
If I use a test deployment as mentioned on https://developers.google.com/apps-script/add-ons/how-tos/testing-editor-addons, it works. But this works only via the script project where GCP project is configured. For other, it gives "Google developers console API activation" error.
So question here is - is it mandatory to provide the GCP project ID even for test deployments? Is there any configuration that I can use for getting around this problem?
Please note - I can always create a test deployment from the production version of App Script project (where GCP project id is added). But I would like to maintain 2 versions possibly without having to add GCP project in development version.
Kindly advice.
It depends on how you or your team have designed the solution. Also it's depends on if the solution is requiring users to authorize all the scopes, if it's using a service account, among other factors.
One design might be based on the use of a single Google Cloud Platform standard project to handle all the OAuth authorizations.
Another design might be based on using two or more Google Cloud Platform projects. I.E. you could use a default project for Google Apps Script and a standard project another for the Google APIs like BigQuery. This setup might require the use of a service account.
Related
Create a development environment and use a deployment tool for Google apps script in spreadsheets
Best development setup for developing gmail add-ons locally?
I am not sure if this changed recently with the new IDE, but I thought that the deployment ID / URL of one's web app didn't change when one created additional versions. However, at this moment I am confused.
In my process.env, I have a link to my GAS URL which performs a doGet(e). However, when I go to manage deployments in my GAS file, I cannot find the corresponding deployment ID / link anywhere (not under Active nor Archived), yet, the code is working and reflects the latest changes in my script, so I believe it's the head deployment. Is this correct, or am I using some legacy deployment ID or something that's hidden?
Or perhaps asked differently, if I have the /macros/s/{deployment_id}/exec URL, is there a way within my Google account to find the corresponding script file and version / deployment?
Lastly, if the documentation recommends using versioned deployments, does this mean we have to update the GAS URL each time (e.g., if it's a public facing web app)?
Edit: others have encountered this: https://groups.google.com/g/google-apps-script-community/c/qhiqjGabQpI/m/q5i31yydCAAJ
To view the all deployment IDs, including HEAD (aka version 0):
Switch to Legacy Editor
Go to Publish => Deploy From Manifest
You'll get a list of deployment, with ID next to each one
Copy the ID of Version 0
Paste the ID in the corresponding Google Cloud Console => Configuration
Switch again to New Editor :)
If you are using Clasp with Apps Script for the development simply you can use clasp commands agents the given App Script Project.
clasp deployments to see the list of deployments including HEAD
this document maybe can help you.
Follow step 5 and step 6 in the IMPORTANT POINT.
5. Update the deployment as follows:
a. Open "New deployment" dialog with "Deploy" -> "Manage deployments".
b. For the 1st deployment, click the pencil icon for editing the deployment.
c. Set "version" as "New version".
d. When you want to change the description, please modify it.
e.Click "Deploy" button.
6.Testing
Please use above sample curl command. By this, you can confirm that sample2 is returned without changing the endpoint.
Answer:
There ways of viewing and editing deployments is set out in this article, which I will go through below. If you can not view the desired deployment using these methods, then I would urge you to contact Google Workspace support.
More Information:
As per the documentation on creating and managing deployments:
There are two types of deployments:
Head deployments, which are always synced to the current project code.
Versioned deployments, which are connected to a specific project version.
View versioned deployments
New editor:
To view the deployments of an Apps Script project, at the top, click Deploy > Manage deployments.
Find a deployment ID
New editor:
Open the Apps Script project.
At the top right, click Deploy > Manage deployments.
The deployment ID appears on the current deployment.
References:
Create and manage deployments | Apps Script | Google Developers
Before I start, I'm having the same issue as this question and this question. Unfortunately, neither of those solutions is working for me.
I have an add-on in the G Suite Marketplace. There are two separate entries, one for a Docs version and one for a Slides version. Now that the Chrome web store is being phased out for add-ons, I want to combine them into the same listing (afaik, that wasn't possible in the web store, only G Suite Marketplace).
Because of this, I now need to associate the Apps Script projects for both the Docs and Slides version with the same Cloud project. I'm hoping to migrate both to the Docs version because that has more users so hopefully fewer people will be impacted by the move.
I've taken the following steps:
Duplicate the Slides Apps Script project (to avoid messing with the original Marketplace listing until everything is set)
Go into the Cloud Platform settings for the new Slides App Script project
Enter the Cloud Platform project number for the Docs add-on
When I do this, I get an error that says "Project does not exist or you need edit access to it."
The weird thing is that if I try these steps to switch both projects to the Slides version in the Marketplace, it works. Because of this, I'm assuming there's some issue with the Cloud Platform project for the Docs version, but I can't seem to figure out what it is. Does anyone have any tips for common settings that could cause this error?
I was having the same problem and found out that it has something to do with the Shared Drive you have for a team.
Using the answer found by Ian: Google Apps Script cannot convert from GAS managed to specific Cloud Project
If the project is in a Shared Google Drive, like a team drive, you are no longer the owner (even if it says you are).
I couldn't create a new project in a shared drive and convert it to a Cloud Managed Project.
The only way I could do it was to create a new project on my account, in My Drive, and convert that to a Cloud Managed Project, THEN move it to the shared drive. (Once it is in a shared drive, you can't MOVE it back out.) However, if it is a Cloud Managed Project, you can add more scopes to the project after it is in the shared drive. - Once this new project is setup, then copy over your code for your old copy, and point all links to the new one.
I am not able to switch google cloud platform project in GAS editor.
What I am doing is…
Open the google sheet GAS editor
Open Resource --> Cloud Platform Project
Enter project number that I want to connect
With the process above, I was able to switch a cloud platform project but now it returns an error
‘Project does not exist, or you need edit access to it.’
I am using the same cloud project and same account(editor) that I used before and properly worked. I tried do the same with a owner account, but it didn’t work, either.
Also, this cloud project is not a default project nor a hidden project. (If it does, I guess it should not be able to access through GAS editor from the beginning)
I have checked documentation below, but it tells me only case when switching to a hidden project.
https://developers.google.com/apps-script/guides/cloud-platform-projects
Does anyone have a solution or suggestion??
Thank you for the help in advance.
Problem Solved.
I figured out that OAuth IDs which are generated when make connection docs to the cloud project are not be deleted even though delete actual document files.
What I have done is...
Login Google Cloud Platform
Go to APIs&Services --> Credentials
On OAuth 2.0 client IDs, delete unnecessary contents from the list
Back to your docs and switch the cloud project.
We are no longer able to associate our Apps Script projects with our Cloud platform project. When going to Resources: Cloud platform project in the GAS editor, and entering the project ID, it says "Project doesn't exist or you need Edit access to it.". The project definitely exists and the same Google account is an owner of it. With the same workflow, we previously managed to associate many projects.
Is there maybe a limit on how many GAS projects can be associated with one Cloud project? We've associated about two dozen recently, and then it started to produce this error. Or what could be going on?
This is explained in details here:
https://developers.google.com/apps-script/guides/cloud-platform-projects
Specifically, quoting:
"There may be cases in which you want multiple Apps Script projects to share the same Google Cloud Platform project. Since these default Cloud Platform projects for Apps Scripts are hidden, they cannot be used as the destination projects for a switch. If you see a "Project does not exist or you need edit access to it" error when attempting to switch a script's project, that usually means you are attempting to move it to one of these default projects.
To get around this restriction, create a new, blank Cloud Platform project, and use the steps above to add each script to that."
I was able to solve this by switching from the Classic Editor to the New Editor, adding the Cloud Project, then reverting back to the Classic Editor (if needed).