From 94fbe591bc217d396872bd739ff59cfb5fa30fb7 Mon Sep 17 00:00:00 2001 From: Margubur Rahman Date: Mon, 13 Oct 2025 15:52:58 +0000 Subject: [PATCH] refactor(gsutil): Migrate gsutil to gcloud storage --- kokoro/ubuntu/release.sh | 2 +- kokoro/windows/continuous.bat | 2 +- release/copy_repo_to_final_location.py | 8 ++++---- release/copy_repo_to_final_location_test.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kokoro/ubuntu/release.sh b/kokoro/ubuntu/release.sh index 68a21d1edf..0626a7965b 100755 --- a/kokoro/ubuntu/release.sh +++ b/kokoro/ubuntu/release.sh @@ -7,7 +7,7 @@ set -o errexit -gsutil -q cp "gs://ct4e-m2-repositories-for-kokoro/m2-cache.tar" - \ +gcloud storage cp "gs://ct4e-m2-repositories-for-kokoro/m2-cache.tar" - \ | tar -C "${HOME}" -xf - export CLOUDSDK_CORE_DISABLE_USAGE_REPORTING=true diff --git a/kokoro/windows/continuous.bat b/kokoro/windows/continuous.bat index e0155fea3d..2f70cd07bb 100644 --- a/kokoro/windows/continuous.bat +++ b/kokoro/windows/continuous.bat @@ -10,7 +10,7 @@ java -version rem To speed up build, download and unpack an M2 repo cache. pushd %USERPROFILE% -call gsutil.cmd -q cp "gs://ct4e-m2-repositories-for-kokoro/m2-cache.tar" . +call gcloud.cmd storage cp "gs://ct4e-m2-repositories-for-kokoro/m2-cache.tar" . @echo on tar xf m2-cache.tar && del m2-cache.tar popd diff --git a/release/copy_repo_to_final_location.py b/release/copy_repo_to_final_location.py index dc17bbfa96..a6d816f400 100755 --- a/release/copy_repo_to_final_location.py +++ b/release/copy_repo_to_final_location.py @@ -63,18 +63,18 @@ def _IsVersionString(string): def _GcsLocationExists(gcs_location): try: subprocess.check_output( - ["gsutil", "ls", gcs_location], stderr=subprocess.STDOUT) + ["gcloud", "storage", "ls", gcs_location], stderr=subprocess.STDOUT) return True except subprocess.CalledProcessError: return False def _GetCopyCommand(origin, destination): - return ["gsutil", "-m", "cp", "-R", origin, destination] + return ["gcloud", "storage", "cp", "--recursive", origin, destination] def _GetPublicAccessCommand(target): - return ["gsutil", "-m", "acl", "ch", "-R", "-u", "AllUsers:R", target] + return ["gcloud", "storage", "objects", "update", "--recursive", "--add-acl-grant=entity=AllUsers,role=READER", target] def main(argv): @@ -89,7 +89,7 @@ def main(argv): print("# entered is correct, delete it first and try again.") print("#") print("# Command to delete:") - print("# gsutil -m rm " + gcs_destination + "/**") + print("# gcloud storage rm --recursive " + gcs_destination) exit(1) # Copy the repo diff --git a/release/copy_repo_to_final_location_test.py b/release/copy_repo_to_final_location_test.py index b7c7a0ca67..1819f2e081 100755 --- a/release/copy_repo_to_final_location_test.py +++ b/release/copy_repo_to_final_location_test.py @@ -55,12 +55,12 @@ def testGcsLocationExists_NonExistingLocation(self): _GcsLocationExists("gs://cloud-tools-for-eclipse/non-existing")) def testGetCopyCommand(self): - self.assertEquals(["gsutil", "-m", "cp", "-R", "origin", "destination"], + self.assertEquals(["gcloud", "storage", "cp", "--recursive", "origin", "destination"], _GetCopyCommand("origin", "destination")) def testGetPublicAccessCommand(self): self.assertEquals( - ["gsutil", "-m", "acl", "ch", "-R", "-u", "AllUsers:R", "target"], + ["gcloud", "storage", "objects", "update", "--recursive", "--add-acl-grant", "AllUsers:R", "target"], _GetPublicAccessCommand("target"))