我有一个Spring Boot应用程序,我想将其自动部署到App Engine。我不想创建docker映像然后进行部署。由于“找不到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.
根据文档,在src / main / appengine中创建app.yaml文件。 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]
为了触发构建,我必须指定cloudbuild.yaml文件。该文件的内容为:
steps:
- name: 'gcr.io/cloud-builders/mvn'
args: ['appengine:deploy','-Pprod']
云构建器的官方文档建议使用“安装”作为mvn步骤的参数。但是此步骤不会部署应用程序。
我缺少任何配置吗?
答案 0 :(得分:1)
在后台,appengine:deploy
目标使用Cloud SDK实际部署您的应用程序。 gcr.io/cloud-builders/mvn
映像未提供它(每个Cloud Build步骤都在其自己的容器中运行)。
您可以使用单独的构建步骤来安装和部署您的应用,例如:
steps:
- name: 'gcr.io/cloud-builders/mvn'
args: ['install']
- name: 'gcr.io/cloud-builders/gcloud'
args: ['app', 'deploy']
答案 1 :(得分:0)
通过略微修改LundinCast上面建议的解决方案来工作。此外,appengine maven插件需要更新到2.0.0+。此版本自动下载必要的依赖项。
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']