I'm attempting to achieve automatic build and deployment on the Google Cloud Platform using build triggers with Google App Engine. The build is currently triggered when I push to the master branch of my linked Github repository.
The application is a Spring Boot application with Maven, which is serving a simple API. I'm trying to issue the mvn appengine:deploy in my cloudbuild.yaml file, which looks like this:
# 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.
The triggered build run for about 20 seconds, and then fails with the following error message:
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
<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.
The
appengine-maven-pluginrequires the Cloud SDK to be installed. Since thegcr.io/cloud-builders/mvndocker image does not have it installed, theappengine:deploygoal fails.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. Then deploy it to your GCR and use it in your
cloudbuild.yamlinstead ofgcr.io/cloud-builders/mvn.2) Do not use
appengine-maven-plugin, but split the build and deploy into several steps.Note that after building the WAR, you might need to use
gcloudseveral times to stage the app before callinggcloud app deploy.