1

I am using the Google App Script java API to deploy the code. I am performing the following steps:

1. Update the latest code

Content content = new Content();
content.setFiles(files);
Content updatedContent = scriptService.projects().updateContent(scriptId, content).execute();

2. Create a new version

Version version = new Version();
version.setDescription("test create version");
Version createdVersion = scriptService.projects().versions().create(scriptId, version).execute();

3. Deploy the latest version

DeploymentConfig deploymentConfig = new DeploymentConfig();
deploymentConfig.setDescription("test deployment");
deploymentConfig.setVersionNumber(createdVersion.getVersionNumber());
deploymentConfig.setManifestFileName("appsscript");

Deployment deploymentCreated = scriptService.projects().deployments().create(scriptId, deploymentConfig).execute();

When I log into script.google.com I am able to view the latest version that I created. It shows the status as deployed. In the script editor, I am able to view the latest code as well. Now, when I invoke the apps script the requests are still handled by the older version. Could somebody let me know if there is something wrong with the way I am using the API?

Mithun
  • 7,747
  • 6
  • 52
  • 68
  • Is this a Java or PHP command-line application? – Alan Wells Nov 20 '18 at 13:53
  • This is a java based application – Mithun Nov 20 '18 at 14:16
  • 1
    Add Java to the tags and add that it's Apps Script API using Java. And maybe link to the Java quick start. [https://developers.google.com/apps-script/api/quickstart/java](https://developers.google.com/apps-script/api/quickstart/java) The code is affecting Apps Script files, but none of the code is actually Apps Script code. It's Java and API code. – Alan Wells Nov 20 '18 at 14:50
  • The screen: "Publish API executable" - Does it show that the deployed version is the latest version? – TheMaster Nov 20 '18 at 20:22
  • Yes, the `Versions` drop-down shows the latest version. But, in the "Publish API executable" screen the newest version is not pre-selected in the drop-down. – Mithun Nov 21 '18 at 07:36
  • This seems to be a known issue https://github.com/google/clasp/issues/63 Try creating a issue at https://issuetracker.google.com/issues/new – TheMaster Nov 21 '18 at 21:33
  • Created an issue in Issue tracker - https://issuetracker.google.com/issues/119886997 – Mithun Nov 23 '18 at 05:57

1 Answers1

0
  1. try to set deployment version (greater then old one).

    Version version = new Version();
    version.setDescription("test create version");
    version.setVersionNumber(3);
    Version createdVersion = scriptService.projects().versions().create(scriptId, version).execute();
    
  2. delete the deployment when it's no longed needed

    service.projects().deployments()
        .delete(scriptId, deploymentCreated.getDeploymentId()).execute();
    
babay
  • 4,689
  • 1
  • 26
  • 40