Skip to content

Instantly share code, notes, and snippets.

@jed204
Created October 30, 2019 05:36
Show Gist options
  • Save jed204/e2ee82eab958d999b98c082bf4290624 to your computer and use it in GitHub Desktop.
Save jed204/e2ee82eab958d999b98c082bf4290624 to your computer and use it in GitHub Desktop.
Google Cloud Build Maven Build with Cache
steps:
# Grab cached M2 repo
- name: gcr.io/cloud-builders/gsutil
id: Get M2 Cache
args: ['cp', 'gs://BUCKET_NAME/m2.tar.gz', 'm2.tar.gz']
# See https://github.com/GoogleCloudPlatform/cloud-builders-community to get the tar command
- name: gcr.io/PROJECT_ID/tar
id: Expand M2 Cache
args: ['xpzf', 'm2.tar.gz']
# Optional, we had some extra settings to include
- name: 'gcr.io/cloud-builders/gsutil'
id: Get setting.xml
args: ['cp', 'gs://BUCKET_NAME/settings.xml', 'custom-settings.xml']
# The maven.repo.local setting was key
- name: 'gcr.io/cloud-builders/mvn'
id: Test and Build
args: ['-Dmaven.repo.local=/workspace/.m2/repository', '--settings', 'custom-settings.xml', 'deploy']
# Update M2 repo cache
- name: gcr.io/PROJECT_ID/tar
id: Compress M2 Cache
args: ['cpzf', 'm2.tar.gz', '.m2']
- name: gcr.io/cloud-builders/gsutil
id: Save M2 Cache
args: ['cp', 'm2.tar.gz', 'gs://BUCKET_NAME/m2.tar.gz']
@hazzyeer
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment