google-apps-scriptdeploymentweb-applicationsversion

Google Apps Script - Deploy as Webapp - new version every time?


Changes I make to my Code.gs file don't seem to be recognized unless I deploy as webapp under a new version. Is this the designed behavior or am I doing something wrong elsewhere?


Solution

  • How about this answer? Please think of this as just one of several answers.

    At the project that Web Apps is deployed, when the script in the project was modified, the Web Apps is required to be redeployed as new version. By this, the latest script is reflected to the Web Apps. This is the normal specification. I think that this situation might be supposed to separate the developing script and stable script.

    Automatically reflecting latest script to Web Apps

    There are several methods that the latest script can be automatically reflected to Web Apps when the script was modified.

    1. Use developer mode

    When the developer mode is used, the latest script can be used for the Web Apps without redeploying as new version. When you deploy the Web Apps, you can see "latest code" which has a link. The URL is like https://script.google.com/macros/s/###/dev. By using this URL, when the script was modified, you can use the latest script at Web Apps.

    As an important point, when you use this, please use the access token. By this, you can access to the Web Apps. The sample curl can be seen at here.

    2. Use library

    If you want to automatically use the latest script using the URL like https://script.google.com/macros/s/#####/exec, it can be achieved using a library. The preparation is as follows.

    1. Create 2 projects which are project "A" and project "B".
      • Project "A" is used as the project deployed Web Apps. Project "B" is used as a GAS library.
    2. At Project "A", install Project "B" as the GAS library. At that time, set "Development mode" as "Turn ON".
    3. At Project "A", put the function function doGet(e) {return library.run(e)}.
      • In this case, the library name supposes library.
    4. At Project "B", put the function function run(e) { do something }.
      • When you want to modify the script of Web Apps, please modify the script of Project "B".

    By above settings, when the script of Project "B" is modified, the latest script is automatically reflected to the Web Apps. By this, it is not required to redeploy as new version.

    References:

    If I misunderstood your question and this was not the direction you want, I apologize.