diff --git a/release/cloudbuild-dev-resource.yaml b/release/cloudbuild-dev-resource.yaml index d3dedfe133c..fa31e849465 100644 --- a/release/cloudbuild-dev-resource.yaml +++ b/release/cloudbuild-dev-resource.yaml @@ -9,6 +9,9 @@ # To trigger a build automatically, follow the instructions below and add a trigger: # https://cloud.google.com/cloud-build/docs/running-builds/automate-builds steps: +# Download saved Gradle distribution from GCS and install it. +- name: 'gcr.io/${PROJECT_ID}/builder:live' + entrypoint: ./release/install_gradle.sh # Compile javadoc - name: 'gcr.io/${PROJECT_ID}/builder:live' entrypoint: /bin/bash diff --git a/release/cloudbuild-kythe.yaml b/release/cloudbuild-kythe.yaml index 91ecd2f7dbe..14a6b7428c5 100644 --- a/release/cloudbuild-kythe.yaml +++ b/release/cloudbuild-kythe.yaml @@ -41,6 +41,7 @@ steps: export KYTHE_OUTPUT_DIRECTORY="$${PWD}/kythe_output" mkdir -p $${KYTHE_OUTPUT_DIRECTORY} mkdir -p $${KYTHE_OUTPUT_DIRECTORY}/merged + ./release/install_gradle.sh ./gradlew clean testClasses \ -Dno_werror=true -PenableCrossReferencing=true # Merge kzip files diff --git a/release/cloudbuild-nomulus.yaml b/release/cloudbuild-nomulus.yaml index b3cdc6436b2..723cc8a1b8f 100644 --- a/release/cloudbuild-nomulus.yaml +++ b/release/cloudbuild-nomulus.yaml @@ -7,6 +7,9 @@ steps: # Create a directory to store the artifacts - name: 'gcr.io/${PROJECT_ID}/builder:latest' args: ['mkdir', 'nomulus'] +# Download saved Gradle distribution from GCS and install it. +- name: 'gcr.io/${PROJECT_ID}/builder:latest' + entrypoint: ./release/install_gradle.sh # Run tests - name: 'gcr.io/${PROJECT_ID}/builder:latest' # Set home for Gradle caches. Must be consistent with last step below diff --git a/release/cloudbuild-proxy.yaml b/release/cloudbuild-proxy.yaml index 5a5a3055b42..f628d2a11be 100644 --- a/release/cloudbuild-proxy.yaml +++ b/release/cloudbuild-proxy.yaml @@ -7,6 +7,9 @@ # To trigger a build automatically, follow the instructions below and add a trigger: # https://cloud.google.com/cloud-build/docs/running-builds/automate-builds steps: +# Download saved Gradle distribution from GCS and install it. +- name: 'gcr.io/${PROJECT_ID}/builder:latest' + entrypoint: ./release/install_gradle.sh # Build the proxy docker image. - name: 'gcr.io/${PROJECT_ID}/builder:latest' args: diff --git a/release/cloudbuild-release.yaml b/release/cloudbuild-release.yaml index 48cc9746b61..e1f9a7592eb 100644 --- a/release/cloudbuild-release.yaml +++ b/release/cloudbuild-release.yaml @@ -265,7 +265,6 @@ steps: fi else gcloud storage cp $gradle_bin gs://${gcs_loc}/ - gcloud storage objects update --predefined-acl=publicRead gs://${gcs_loc}/${gradle_bin} fi rm ${gradle_bin} sed -i s%services.gradle.org/distributions%storage.googleapis.com/${gcs_loc}% \ diff --git a/release/install_gradle.sh b/release/install_gradle.sh new file mode 100755 index 00000000000..92f3ecb7728 --- /dev/null +++ b/release/install_gradle.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# Copyright 2019 The Nomulus Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script should be invoked from the Gradle root. It downloads the +# gradle distribution saved on GCS, and sets Gradle's distribution URL +# to the local copy. This is necessary since when accessing a GCS bucket +# using http, the bucket must have public access, which is forbidden by +# our policy. + +set -e + +gradle_url=$(grep distributionUrl gradle/wrapper/gradle-wrapper.properties \ + | awk -F = '{print $2}' | sed 's/\\//g') +gradle_bin=$(basename $gradle_url) +gcs_loc="domain-registry-maven-repository/gradle" + +gcloud storage cp "gs://${gcs_loc}/${gradle_bin}" . +local_url="file\\\://${PWD}/${gradle_bin}" +sed -i "s#distributionUrl=.*#distributionUrl=${local_url}#" \ + gradle/wrapper/gradle-wrapper.properties