Home > Enterprise >  Maven upgrade unable to run package appengine:stage
Maven upgrade unable to run package appengine:stage

Time:11-28

I have a Java 8 Spring Boot app that is deployed to Google App Engine and being built via GCP CloudBuild. I am trying to upgrade it from Java 8 to Java 11.

In the cloudbuild.yaml file, I changed:

- id: 'Build and Test'
  name: 'gcr.io/cloud-builders/mvn:3.5.0-jdk-8'
  args: ['package', 'appengine:stage']

to:

- id: 'Build and Test'
  name: 'maven:3.8.3-jdk-11'
  args: ['package', 'appengine:stage']

When I run the CloudBuild, this step now suddenly fails with the following error:

docker.io/library/maven:3.8.3-jdk-11
/usr/local/bin/mvn-entrypoint.sh: 50: exec: package: not found

In its previous configuration, it was running just fine. The entire cloudbuild.yaml file is:

steps:
  - id: 'copy file'
    name: 'ubuntu'
    args: ['cp', 'src/main/appengine/app.yaml', src/main/appengine/app.yaml]

  - id: 'Build and Test'
    name: 'maven:3.8.3-jdk-11'
    args: ['package', 'appengine:stage']

What is going on here? Does the gcr.io/cloud-builders/mvn:3.5.0-jdk-8 image somehow understand mvn package appengine:stage, whereas the maven:3.8.3-jdk-11 image doesn't? Mainly I just need someone to help me understand why I'm getting the error. If anyone could also lend some suggestions for how to fix or circumvent it, that'd be greatly appreciated as well. Thanks in advance!

CodePudding user response:

Reviewing Google documentation about migrating to the Java 11 runtime, I found that App Engine standard environment allows you to use several of App Engine's packaged services and APIs in the Java 11 runtime, reducing runtime conversion effort and complexity.

The Project Engine API JAR allows your Java 11 app to contact the bundled services APIs and access most of the same functionality as the Java 8 runtime.

You can also use Google Cloud products that are equivalent to the App Engine packaged services in functionality.

Adding overview of the migration process documentation.

The process to follow is:

  • Download Cloud SDK.
  • Migrate from the standalone App Engine Maven plugin to the Cloud SDK-based Maven plugin or the Cloud SDK-based Gradle plugin.
  • Install the App Engine API JAR if you are using the App Engine bundled services.
  • Migrate your XML files to the equivalent yaml files.

Now, regarding the issue you are getting, you should specify the whole path of the script because /usr/src/app may not be in your path. You must also ensure that your entrypoint.sh is executable; however, depending on your circumstance, docker will duplicate the permissions precisely as they are on your build host, so this step may not be necessary.

Additional suggestion is that you can't use single quotes ' for the entrypoint/command, you can try with ,

CodePudding user response:

It was so obvious in hindsight. I needed to specify mvn as the entrypoint command in the step like so:

- id: 'Build and Test'
  entrypoint: mvn
  name: 'maven:3.8.3.0-jdk-11'
  args: ['package','appengine:stage']
  • Related