简体   繁体   中英

Google AppEngine - Auto deploy to App engine failing

I have a Spring boot application which I want to auto-deploy to App Engine. I don't want to create the docker image then deploy it. The build is failing due to 'Cloud SDK not found error'

[ERROR] Failed to execute goal com.google.cloud.tools:appengine-maven-plugin:1.3.2:deploy (default-cli) on project location-finder-rest-api: Execution default-cli of goal com.google.cloud.tools:appengine-maven-plugin:1.3.2:deploy failed: The Google Cloud SDK could not be found in the customary locations and no path was provided. 

I followed all the guidelines at https://cloud.google.com/source-repositories/docs/quickstart-triggering-builds-with-source-repositories .

As per the documentation, app.yaml file is created at src/main/appengine. The contents of app.yaml is

# [START runtime]
runtime: java
env: flex

handlers:
- url: /.*
  script: this field is required, but ignored

runtime_config:  # Optional
  jdk: openjdk8

manual_scaling:
  instances: 1
# [END runtime]

In order to trigger the build, I have to specify the cloudbuild.yaml file. The contents of this file are:

steps:
- name: 'gcr.io/cloud-builders/mvn'
  args: ['appengine:deploy','-Pprod']

The official document for cloud-builder suggest using 'install' as an argument to the mvn step. But this step does not deploy the application.

Am I missing any configuration?

Under the hood, the appengine:deploy goal uses the Cloud SDK to actually deploy your app. It isn't provided by the gcr.io/cloud-builders/mvn image (each Cloud Build step runs in its own container).

You could use separate build steps to install and deploy your app, something like:

steps:
- name: 'gcr.io/cloud-builders/mvn'
  args: ['install']
- name: 'gcr.io/cloud-builders/gcloud'
  args: ['app', 'deploy'] 

It worked by making slight modifications to the solution suggested above by LundinCast. Moreover, appengine maven plugin needs to be updated to 2.0.0+. This version automatically downloads the necessary dependencies.

steps:
- id: 'Stage app using mvn appengine plugin on mvn cloud build image'
  name: 'gcr.io/cloud-builders/mvn'
  args: ['package', 'appengine:stage', '-Pprod']
- id: "Deploy to app engine using gcloud image"
  name: 'gcr.io/cloud-builders/gcloud'
  args: ['app', 'deploy', 'target/appengine-staging/app.yaml']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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