1
0
mirror of https://github.com/google/nomulus synced 2026-04-24 10:10:46 +00:00

Use downloaded Gradle distribution on Cloud Build (#2918)

This way we get around the http url and no longer needs public access on
the GCS bucket.
This commit is contained in:
Weimin Yu
2025-12-30 21:08:04 +00:00
committed by GitHub
parent f9c22ff1c5
commit 7e9d4c27d1
6 changed files with 42 additions and 1 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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:

View File

@@ -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}% \

32
release/install_gradle.sh Executable file
View File

@@ -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