0

自最近 appcfg 弃用以来出现问题。我的项目是用 ant 在到 GCP 的詹金斯管道中构建的 java8。

[exec] 95% Application deployment failed. Message: Deployments using appcfg are no longer supported. See https://cloud.google.com/appengine/docs/deprecations

在 GCP 中,我有 3 个项目,开发、测试和直播。我使用参数构建以通过 jenkins 匹配项目。例如,使用测试构建通过了部署测试的参数。

来自 ant build.xml 的片段:

<target name="deploy-test" depends="build, setup-for-appengine, setup-for-test, deploy"></target>

<target name="deploy-live" depends="build, setup-for-appengine, setup-for-live, deploy"</target>

<target name="setup-for-test" description="Configuration for test">
  (Some config stuff e.g. replacing app id and version in the appengine-web.xml)
</target>

<target name="deploy" description="Upload to App Engine.">
  <exec executable="${FILE PATH TO appcfg.sh}" failonerror="true">
    <arg line="update '${.ENV FILE PATH}/war'" />
  </exec>
</target>

我已经从 App Engine SDK 更新到 Cloud SDK 并迁移到 gcloud CLI。我在 build.xml 中的可执行文件现在是:

<target name="deploy" description="Upload to App Engine.">
  <exec executable="${FILE PATH TO gcloud executable}" failonerror="true">
    <arg line="app deploy '${.ENV FILE PATH}/war'" />
  </exec>
</target>

此部署将通过 jenkins 成功运行,但这会导致 500 错误并针对 dev 而不是 test。唯一改变的是从 App Engine SDK 到 Cloud SDK 并迁移到 gcloud 命令的文件路径。

     [exec] descriptor:      [filepath/appengine-web.xml]
     [exec] source:          [filepath/war]
     [exec] target project:  [dev]
     [exec] target service:  [default]
     [exec] target version:  [version no.]
     [exec] target url:      [https://dev.appspot.com]

任何方向将不胜感激。提前致谢

4

2 回答 2

1

通过添加 --project 和 --version 作为解决方案,并且不再在 appengine-web.xml 中使用。添加 -q 以传递任何提示,例如更新。

<target name="deploy" description="Upload to App Engine.">
   <exec executable="${FILE PATH TO gcloud executable}" failonerror="true">
     <arg line="app deploy '${.ENV FILE PATH}/war/WEB-INF/appengine-web.xml' --project=${application_id} --version=${application_version} -q" />
   </exec>
 </target>

我在 GCP 和更改项目的 gservice 帐户范围的权限方面也遇到了一些问题,现在已解决。

于 2020-10-14T08:56:16.490 回答
0

您需要指定 appengine-web.xml 文件的路径。

<target name="deploy" description="Upload to App Engine.">
  <exec executable="${FILE PATH TO gcloud executable}" failonerror="true">
    <arg line="app deploy '${.ENV FILE PATH}/war/WEB-INF/appengine-web.xml'" />
  </exec>
</target>

另外,设置要部署的版本,因为自版本 311.0.0 (2020-09-22) 起, appengine-web.xml 中的应用程序版本元素不受尊重。

 <target name="deploy" description="Upload to App Engine.">
   <exec executable="${FILE PATH TO gcloud executable}" failonerror="true">
     <arg line="app deploy '${.ENV FILE PATH}/war/WEB-INF/appengine-web.xml'" />
     <arg line="-v ${version.name}"/>
   </exec>
 </target>

请注意,这仅适用于 Java 8。对于 Java 11,您需要将您的应用程序打包在一个可执行 jar 中。

gcloud app deploy ~/my_app/my_jar.jar

您还需要从现有应用程序中删除appengine-web.xml文件并将其替换为app.yaml文件

请参阅https://cloud.google.com/appengine/docs/standard/java11/java-differences

于 2020-10-11T03:23:30.060 回答