简体   繁体   English

如何在部署应用引擎应用时设置自定义版本?

[英]How to set a custom version when deploying an app engine application?

I am deploying an app to Google app engine standard. 我正在将应用部署到Google应用引擎标准。 It's a Java/Kotlin application, but the question isn't necessarily specific to that. 这是一个Java / Kotlin应用程序,但问题不一定是具体的。 I am using the latest Gradle plugin, and the answer could be specific to that. 我正在使用最新的Gradle插件,答案可能是具体的。

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 . 像所有这些年一样,我指定一个项目ID,比如MyProject ,以及一个版本号/字符串,比方说1-2-0 Both pieces of information would historically go into the appengine-web.xml file ( app.yaml for Python). 历史上,这两条信息都会进入appengine-web.xml文件(Python的app.yaml )。 They still can be set there, but are then being ignored, as the deployment process points out prominently. 它们仍然可以设置在那里,但随后被忽略,因为部署过程突出显示。

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 ). 现在必须将项目ID MyProject指定为常规glcoud命令行界面配置的一部分(可以通过gcloud config configurations list )。 The Gradle plugin seems to be picking it up from there just fine. Gradle插件似乎从那里捡起来就好了。

For the version 1-2-0 , however, I cannot figure out where and how to set it. 然而, 对于版本 1-2-0 ,我无法弄清楚在何处以及如何设置它。 So, on deployment I always end up with a new default like 20170604t124930 , and lots of redundant app versions. 因此,在部署时,我总是最终得到一个新的默认值,如20170604t124930 ,以及许多冗余的应用程序版本。

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. 对于以前使用appcfg (或者是glcoud命令?)进行部署的Python应用程序,我将项目ID和版本都指定为命令行参数。 The Gradle pluging must be finding (or not finding) this information somewhere else. Gradle pluging必须在其他地方找到(或没有找到)这些信息。 The Gradle file's version = '1.2.0-SNAPSHOT' of course is just for the generated jar/war. Gradle文件的version = '1.2.0-SNAPSHOT'当然只适用于生成的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! 谢谢!

The simple answer can be found at the bottom of the App Engine Gradle Plugin Tasks and Properties . 简单的答案可以在App Engine Gradle插件任务和属性的底部找到。 Just add this to build.gradle : 只需将此添加到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
  }
}

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 . 我的困惑似乎源于这样一个事实:有一个旧的Gradle插件和新的插件, 处理确实在两者之间发生了很大的变化 In particular, the new plugin is more dependent on the glcoud configuration. 特别是,新插件更依赖于glcoud配置。 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). 插件as-is允许在Gradle配置中设置项目ID( appengine.deploy.project ),但是,当没有在那里指定时,只从可用项目列表中获取默认值(命令行: gcloud config list project - - 旧的appcfg不再使用了)。

However, there is no such default for the version in the environment, when the version is missing from the Gradle configuration. 但是,当Gradle配置中缺少版本时,环境中的版本没有此类默认值。 A new timestamp string is taken on every deploy in this case. 在这种情况下,每次部署都会采用新的时间戳字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM