如何在部署应用引擎应用时设置自定义版本? [英] How to set a custom version when deploying an app engine application?

查看:151
本文介绍了如何在部署应用引擎应用时设置自定义版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将应用部署到Google应用引擎标准。这是一个Java / Kotlin应用程序,但问题不一定是具体的。我正在使用最新的Gradle插件,答案可能是特定的。

I am deploying an app to Google app engine standard. It's a Java/Kotlin application, but the question isn't necessarily specific to that. I am using the latest Gradle plugin, and the answer could be specific to that.

像这些年一样,我指定了一个项目ID,比方说 MyProject ,以及版本号/字符串,假设 1-2-0 。历史上,这两条信息都会进入 appengine-web.xml 文件(Python的 app.yaml )。它们仍然可以在那里设置,但随后被忽略,因为部署过程突出显示。

Like over all those years, I specify a project ID, let's say MyProject, and a version number/string, let's say 1-2-0. Both pieces of information would historically go into the appengine-web.xml file (app.yaml for Python). They still can be set there, but are then being ignored, as the deployment process points out prominently.

项目ID MyProject 现在必须是指定为一般glcoud命令行界面配置的一部分(可以通过 gcloud配置配置列表查看)。 Gradle插件似乎从那里开始就好了。

The project ID MyProject must now be specified as part of the general glcoud command-line interface configuration (that can be viewed through gcloud config configurations list). The Gradle plugin seems to be picking it up from there just fine.

对于版本 1-2-0 ,但是,我无法弄清楚在哪里以及如何设置它。因此,在部署时,我总是最终得到一个新的默认值,如 20170604t124930 ,以及许多冗余应用程序版本。

For the version 1-2-0, however, I cannot figure out where and how to set it. So, on deployment I always end up with a new default like 20170604t124930, and lots of redundant app versions.

对于以前使用 appcfg (或者是 glcoud 命令?)部署的Python应用程序,我指定了项目ID和版本都作为命令行参数。 Gradle pluging必须在其他地方找到(或没有找到)这些信息。 Gradle文件的版本='1.2.0-SNAPSHOT'当然只适用于生成的jar / war。网上的许多建议,官方Google文档(!)以及此网站此处都已过时,相互矛盾,或者两者(因此,你会原谅我冗长,相当详细的帖子)。谢谢!

For a prior Python app that I used appcfg (or was it a glcoud command?) to deploy for, I specified both project ID and version as command line arguments. The Gradle pluging must be finding (or not finding) this information somewhere else. The Gradle file's version = '1.2.0-SNAPSHOT' of course is just for the generated jar/war. The many suggestions on the web, the official Google documentation (!), and this site like here are outdated, contradictory, or both (therefore, you'll excuse my lengthy, rather detailed post). Thanks!

推荐答案

简单的答案可以在 App Engine Gradle插件任务和属性。只需将其添加到 build.gradle

The simple answer can be found at the bottom of the App Engine Gradle Plugin Tasks and Properties. Just add this to build.gradle:

appengine.deploy.version ='1 -2-0'

或者,作为更广泛的应用引擎插件配置的一部分:

Or, as part of the more extensive app engine plugin configuration:

appengine {

  deploy {
    ...
    version = '1-2-0
  }
}

我的困惑似乎源于这样一个事实:有一个旧的Gradle插件和新的,处理确实在两者之间发生了很大的变化。特别是,新插件更依赖于 glcoud 配置。插件as-is允许在Gradle配置中设置项目ID( appengine.deploy.project ),但是,如果没有在那里指定,则只接受默认值可用项目列表(命令行: gcloud配置列表项目 - 旧的 appcfg 不再使用)。

My confusion seems to stem from the fact that there is the old Gradle plugin and the new one, and handling did change quite a bit between the two. In particular, the new plugin is more dependent on the glcoud configuration. The plugin as-is does allow to set the project ID (appengine.deploy.project) in the Gradle configuration, yet, when not specified there, just takes the default from the list of available projects (command line: gcloud config list project -- the old appcfg isn't used anymore).

但是,当Gradle配置中缺少版本时,环境中的版本没有此类默认值。在这种情况下,每次部署都会采用新的时间戳字符串。

However, there is no such default for the version in the environment, when the version is missing from the Gradle configuration. A new timestamp string is taken on every deploy in this case.

这篇关于如何在部署应用引擎应用时设置自定义版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆