Java8 migrate appcfg to gcloud

153 Views Asked by At

Having issues since the recent appcfg deprecation. My project is java8 built with ant in a jenkins pipeline to GCP.

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

In GCP I have 3 projects, dev, test and live. I build with the parameter to match the project via jenkins. E.g. building with test passes a parameter of deploy-test.

Snippets from 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>

I've updated from App Engine SDK to Cloud SDK and migrated to gcloud CLI. My executable in build.xml is now:

<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>

This deployment will run successfully via jenkins but this results in a 500 error and targets dev instead of test. The only things changed are file paths from App Engine SDK to Cloud SDK and migrated to gcloud command.

     [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]

Any direction will be much appreciated. Thanks in advance

2

There are 2 best solutions below

1
On BEST ANSWER

Resolved by adding --project and --version as and are no longer respected in the appengine-web.xml. -q is added to pass any prompts such as updates.

<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>

I also had some issues with GCP and changing permissions of gservice account scope of projects which is now resolved.

3
On

You need to specify the path to the appengine-web.xml file.

<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>

Also, set the version to deploy because since version 311.0.0 (2020-09-22), application or version elements within appengine-web.xml are not respected.

 <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>

And note, this will only worker under Java 8. For Java 11, you need to package your app in an executable jar.

gcloud app deploy ~/my_app/my_jar.jar

You also need to remove the appengine-web.xml file from your existing application and replace it with an app.yaml file

See https://cloud.google.com/appengine/docs/standard/java11/java-differences