steps:

#
# Extract the cache
#
# The gradle build cache is stored as a tarball in Google Cloud Storage to
# make builds faster.
#
# After extracting the cache to the /build_cache directory, we need to supply
# that to gradle, and include the volume in steps that require the cache.
#
- name: gcr.io/cloud-builders/gsutil
  id: copy_build_cache
  # we use rsync and not cp so that the step does not fail the first time it is run
  args: ['rsync', 'gs://gradle_cache_$PROJECT_ID/', '/build_cache']
  volumes:
  - name: 'build_cache'
    path: '/build_cache'

- name: 'gcr.io/$PROJECT_ID/android-builder'
  entrypoint: 'gradle-build'
  args: ['-g', '.gradle', 'assemble']

- name: gcr.io/cloud-builders/gsutil
  args: ['cp', 'cache.zip', 'gs://gradle_cache_$PROJECT_ID/cache.zip']

steps:

#
# Extract the cache
#
# The gradle build cache is stored as a tarball in Google Cloud Storage to
# make builds faster.
#
# After extracting the cache to the /build_cache directory, we need to supply
# that to gradle, and include the volume in steps that require the cache.
#
- name: gcr.io/cloud-builders/gsutil
  id: copy_build_cache
  # we use rsync and not cp so that the step does not fail the first time it is run
  args: ['rsync', 'gs://gradle_cache_$PROJECT_ID/', '/build_cache']
  volumes:
  - name: 'build_cache'
    path: '/build_cache'

- name: 'gcr.io/$PROJECT_ID/tar'
  id: extract_build_cache
  waitFor: ['copy_build_cache']
    # This might fail the first time, but that's okay
  entrypoint: 'bash'
  args:
  - '-c'
  - |
    tar xpzf /build_cache/cache.tgz -C /build_cache || echo "No cache found."
  volumes:
  - name: 'build_cache'
    path: '/build_cache'

- name: 'gcr.io/$PROJECT_ID/android-builder'
  entrypoint: 'gradle-build'
  args: ['-g', '.gradle', 'assemble']

- name: gcr.io/cloud-builders/gsutil
  args: ['cp', 'cache.zip', 'gs://gradle_cache_$PROJECT_ID/cache.zip']

Add step to extract build cache
Add step to extract build cache

 - This is to avoid using gradle-build file
