简体   繁体   English

Google AppEngine-自动部署到App引擎失败

[英]Google AppEngine - Auto deploy to App engine failing

I have a Spring boot application which I want to auto-deploy to App Engine. 我有一个Spring Boot应用程序,我想自动将其部署到App Engine。 I don't want to create the docker image then deploy it. 我不想创建docker映像然后进行部署。 The build is failing due to 'Cloud SDK not found error' 由于“找不到Cloud SDK错误”,构建失败

[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 . 我遵循了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. 根据文档,在src / main / appengine中创建app.yaml文件。 The contents of app.yaml is app.yaml的内容是

# [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. 为了触发构建,我必须指定cloudbuild.yaml文件。 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. 云构建器的官方文档建议使用“安装”作为mvn步骤的参数。 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. 在后台, appengine:deploy目标使用Cloud SDK实际部署您的应用程序。 It isn't provided by the gcr.io/cloud-builders/mvn image (each Cloud Build step runs in its own container). 它不是由gcr.io/cloud-builders/mvn映像提供的(每个Cloud Build步骤都在其自己的容器中运行)。

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. 它通过对LundinCast上面建议的解决方案进行一些修改来起作用。 Moreover, appengine maven plugin needs to be updated to 2.0.0+. 此外,appengine maven插件需要更新到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']

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

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