Isso é o que estou usando para nossa criação de teste:
cloudbuild.yaml:
steps:
# Get the saved global gradle cache from
# Google Cloud Storage if it exists.
- name: 'gcr.io/cloud-builders/gsutil'
entrypoint: 'sh'
args:
- '-c'
- |
# Global
if gsutil -q stat gs://${PROJECT_ID}_cloudbuild/gradle_global.tar.gz; then
cd /
gsutil cp gs://${PROJECT_ID}_cloudbuild/gradle_global.tar.gz gradle_global.tar.gz
tar -xpzf gradle_global.tar.gz
fi
volumes:
- name: 'gradle_global'
path: /root/.gradle
# Build the java package.
- name: 'gcr.io/cloud-builders/gradle'
entrypoint: 'sh'
args:
- '-c'
- |
# Build the gateway .war package.
./gradlew -Pprod -DskipTests clean bootRepackage
# Move the files needed for the docker image
# to the slim directory.
mv ./build/libs/*.war ./app.war
# Delete all files and folders in the current directory
# except for the 'app.war' and 'Dockerfile'.
find . -type d -exec rm -rf {}
find . -type f -not -name 'app.war' -not -name 'Dockerfile' -delete
volumes:
- name: 'gradle_global'
path: /root/.gradle
# Save the global gradle cache to Google Cloud Storage
- name: 'gcr.io/cloud-builders/gsutil'
entrypoint: 'sh'
args:
- '-c'
- |
# Global
echo 'Creating an archive of /root/.gradle directory'
tar -cpzf gradle_global.tar.gz /root/.gradle/
echo 'Saving archive to Cloud Storage'
gsutil cp gradle_global.tar.gz gs://${PROJECT_ID}_cloudbuild/gradle_global.tar.gz
# Cleaning up
echo 'Deleting gradle*.tar.gz'
rm -f gradle*.tar.gz
volumes:
- name: 'gradle_global'
path: /root/.gradle
- name: 'gcr.io/cloud-builders/docker'
args: ['pull', 'asia.gcr.io/$PROJECT_ID/${IMAGE_NAME}:latest']
# Build the gateway container image.
- name: 'gcr.io/cloud-builders/docker'
args:
- 'build'
- '-t'
- 'asia.gcr.io/${PROJECT_ID}/${IMAGE_NAME}:${COMMIT_SHA}'
- '-t'
- 'asia.gcr.io/${PROJECT_ID}/${IMAGE_NAME}:latest'
- '--cache-from'
- 'asia.gcr.io/${PROJECT_ID}/${IMAGE_NAME}:latest'
- '.'
images:
- asia.gcr.io/${PROJECT_ID}/gateway:${COMMIT_SHA}
- asia.gcr.io/${PROJECT_ID}/gateway:latest
Espero que isso ajude.