Skip to content

Commit 676d917

Browse files
committed
Use downloaded Gradle distribution on Cloud Build
This way we get around the http url and no longer needs public access on the GCS bucket.
1 parent 2562d58 commit 676d917

File tree

6 files changed

+42
-1
lines changed

6 files changed

+42
-1
lines changed

release/cloudbuild-dev-resource.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
# To trigger a build automatically, follow the instructions below and add a trigger:
1010
# https://cloud.google.com/cloud-build/docs/running-builds/automate-builds
1111
steps:
12+
# Download saved Gradle distribution from GCS and install it.
13+
- name: 'gcr.io/${PROJECT_ID}/builder:latest'
14+
entrypoint: ./release/install_gradle.sh
1215
# Compile javadoc
1316
- name: 'gcr.io/${PROJECT_ID}/builder:live'
1417
entrypoint: /bin/bash

release/cloudbuild-kythe.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ steps:
4141
export KYTHE_OUTPUT_DIRECTORY="$${PWD}/kythe_output"
4242
mkdir -p $${KYTHE_OUTPUT_DIRECTORY}
4343
mkdir -p $${KYTHE_OUTPUT_DIRECTORY}/merged
44+
./release/install_gradle.sh
4445
./gradlew clean testClasses \
4546
-Dno_werror=true -PenableCrossReferencing=true
4647
# Merge kzip files

release/cloudbuild-nomulus.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ steps:
77
# Create a directory to store the artifacts
88
- name: 'gcr.io/${PROJECT_ID}/builder:latest'
99
args: ['mkdir', 'nomulus']
10+
# Download saved Gradle distribution from GCS and install it.
11+
- name: 'gcr.io/${PROJECT_ID}/builder:latest'
12+
entrypoint: ./release/install_gradle.sh
1013
# Run tests
1114
- name: 'gcr.io/${PROJECT_ID}/builder:latest'
1215
# Set home for Gradle caches. Must be consistent with last step below

release/cloudbuild-proxy.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
# To trigger a build automatically, follow the instructions below and add a trigger:
88
# https://cloud.google.com/cloud-build/docs/running-builds/automate-builds
99
steps:
10+
# Download saved Gradle distribution from GCS and install it.
11+
- name: 'gcr.io/${PROJECT_ID}/builder:latest'
12+
entrypoint: ./release/install_gradle.sh
1013
# Build the proxy docker image.
1114
- name: 'gcr.io/${PROJECT_ID}/builder:latest'
1215
args:

release/cloudbuild-release.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ steps:
265265
fi
266266
else
267267
gcloud storage cp $gradle_bin gs://${gcs_loc}/
268-
gcloud storage objects update --predefined-acl=publicRead gs://${gcs_loc}/${gradle_bin}
269268
fi
270269
rm ${gradle_bin}
271270
sed -i s%services.gradle.org/distributions%storage.googleapis.com/${gcs_loc}% \

release/install_gradle.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
# Copyright 2019 The Nomulus Authors. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# This script should be invoked from the Gradle root. It downloads the
17+
# gradle distribution saved on GCS, and sets Gradle's distribution URL
18+
# to the local copy. This is necessary since when accessing a GCS bucket
19+
# using http, the bucket must have public access, which is forbidden by
20+
# our policy.
21+
22+
set -e
23+
24+
gradle_url=$(grep distributionUrl gradle/wrapper/gradle-wrapper.properties \
25+
| awk -F = '{print $2}' | sed 's/\\//g')
26+
gradle_bin=$(basename $gradle_url)
27+
gcs_loc="domain-registry-maven-repository/gradle"
28+
29+
gcloud storage cp "gs://${gcs_loc}/${gradle_bin}" .
30+
local_url="file\\\://${PWD}/${gradle_bin}"
31+
sed -i "s#distributionUrl=.*#distributionUrl=${local_url}#" \
32+
gradle/wrapper/gradle-wrapper.properties

0 commit comments

Comments
 (0)