简体   繁体   English

在 Google Cloud App Engine 上构建 Spring Boot 应用程序的触发器

[英]Build trigger for Spring Boot application on Google Cloud App Engine

I'm attempting to achieve automatic build and deployment on the Google Cloud Platform using build triggers with Google App Engine.我正在尝试使用 Google App Engine 的构建触发器在 Google Cloud Platform 上实现自动构建和部署。 The build is currently triggered when I push to the master branch of my linked Github repository.当我推送到链接的 Github 存储库的主分支时,当前会触发构建。

The application is a Spring Boot application with Maven, which is serving a simple API.该应用程序是一个带有 Maven 的 Spring Boot 应用程序,它提供一个简单的 API。 I'm trying to issue the mvn appengine:deploy in my cloudbuild.yaml file, which looks like this:我正在尝试在我的cloudbuild.yaml文件中发出mvn appengine:deploy ,它看起来像这样:

# cloudbuild.yaml
steps:
- name: 'gcr.io/cloud-builders/mvn'
  args: ['appengine:deploy']

The mvn appengine:deploy works as expected when I run it in the Google Cloud Shell, but does not work when it is executed by the build trigger. mvn appengine:deploy在 Google Cloud Shell 中运行时按预期工作,但在构建触发器执行时不起作用。

The triggered build run for about 20 seconds, and then fails with the following error message:触发的构建运行了大约 20 秒,然后失败并显示以下错误消息:

Execution default-cli of goal com.google.cloud.tools:appengine-maven-plugin:1.3.1:deploy failed: The Google Cloud SDK could not be found in the customary locations and no path was provided.

This is my pom.xml configuration这是我的pom.xml配置

<project>
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example.api</groupId>
  <artifactId>api</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>api</name>
  <description>API</description>

  <properties>
    <java.version>1.8</java.version>
    <maven.compiler.source>${java.version}</maven.compiler.source>
    <maven.compiler.target>${java.version}</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <appengine.maven.plugin>1.3.2</appengine.maven.plugin>
    <jetty-maven-plugin>9.3.7.v20160115</jetty-maven-plugin>
    <gcloud-maven-plugin>2.0.9.121.v20160815</gcloud-maven-plugin>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      <version>1.5.9.RELEASE</version>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <version>1.5.9.RELEASE</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>1.5.7.RELEASE</version>
        <executions>
          <execution>
            <goals>
              <goal>repackage</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
         <groupId>com.google.cloud.tools</groupId>
         <artifactId>appengine-maven-plugin</artifactId>
         <version>${appengine.maven.plugin.version}</version>
      </plugin>

      <plugin>
       <groupId>org.eclipse.jetty</groupId>
       <artifactId>jetty-maven-plugin</artifactId>
       <version>${jetty-maven-plugin}</version>
      </plugin>

    </plugins>
  </build>
</project>

Any ideas what I might be missing in my configuration?任何想法我的配置中可能缺少什么? I had a hard time finding any examples online of a cloudbuild.yaml deploying on the Google App Engine using Maven.我很难在网上找到任何使用 Maven 部署在 Google App Engine 上的cloudbuild.yaml示例。

The appengine-maven-plugin requires the Cloud SDK to be installed. appengine-maven-plugin 需要安装 Cloud SDK。 Since the gcr.io/cloud-builders/mvn docker image does not have it installed, the appengine:deploy goal fails.由于gcr.io/cloud-builders/mvn映像未安装它,因此appengine:deploy目标失败。

I can think of two ways of working around this:我可以想到两种方法来解决这个问题:

1) Create a custom Cloud Build build step (Dockerfile) that has both maven and gcloud . 1) 创建一个包含mavengcloud的自定义 Cloud Build 构建步骤 (Dockerfile)。 Then deploy it to your GCR and use it in your cloudbuild.yaml instead of gcr.io/cloud-builders/mvn .然后将其部署到您的 GCR 并在您的cloudbuild.yaml而不是gcr.io/cloud-builders/mvn使用它。

2) Do not use appengine-maven-plugin , but split the build and deploy into several steps. 2)不要使用appengine-maven-plugin ,而是将构建和部署分成几个步骤。

# cloudbuild.yaml
steps:
- name: 'gcr.io/cloud-builders/mvn'
  args: ['package']
- name: 'gcr.io/cloud-builders/gcloud'
  args: ['app', 'deploy', '/workspace/.../target/path-to-app.yaml']

Note that after building the WAR, you might need to use gcloud several times to stage the app before calling gcloud app deploy .请注意,在构建 WAR 之后,您可能需要多次使用gcloudgcloud app deploy程序,然后再调用gcloud app deploy

I recently ran into a similar error message when I upgraded to my new MacBook.我最近在升级到新 MacBook 时遇到了类似的错误消息。 I moved the google-cloud-sdk folder in the /usr/local/share/google/ directory ie /usr/local/share/google/google-cloud-sdk and that solved my issue.我将google-cloud-sdk文件夹移动到/usr/local/share/google/目录中,即/usr/local/share/google/google-cloud-sdk并解决了我的问题。

暂无
暂无

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

相关问题 Spring 在 Google Cloud App Engine 上启动托管 - Spring Boot hosting on Google Cloud App Engine Spring Boot - 将应用程序部署到 Google Cloud App 引擎但缺少 app.yaml - Spring Boot - Deploy application to Google Cloud App engine but missing app.yaml 如何在 Google Cloud Compute Engine 中部署 Spring Boot 应用程序? - How to deploy Spring Boot application in Google Cloud Compute Engine? javax.mail.AuthenticationException-Google云应用引擎-Spring Boot - javax.mail.AuthenticationException - Google cloud app Engine - Spring Boot 不稳定的 Google Cloud Engine - 标准环境 - 延迟(Spring Boot 应用程序) - Erratic Google Cloud Engine - Standard Environment - Latency (Spring Boot App) Google APP Engine 和云 sql :: 无法在 Google 云 sql(我的 sql)中连接 Spring boot 应用程序 - Google APP Engine and cloud sql :: Unable to connect Spring boot app in Google cloud sql (my sql) 在 Google App Engine 上部署 Spring Boot 应用程序时出错 - Error while deploying spring boot application on google app engine Google App Engine 中的 Spring 启动应用程序 http 到 https 重定向 - Spring boot application http to https redirect in Google App Engine 部署后无法访问Google App Engine中的Spring Boot应用程序 - Unable to access Spring Boot application in Google App Engine after deployment 使用 Gitlab CI 将 Spring 引导应用程序部署到 Google App Engine? - Deploy Spring Boot application to Google App Engine using Gitlab CI?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM