Skip to content
15 changes: 13 additions & 2 deletions src/google/adk/cli/cli_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import click
from packaging.version import parse

IS_WINDOWS = os.name == 'nt'
_DOCKERFILE_TEMPLATE: Final[str] = """
FROM python:3.11-slim
WORKDIR /app
Expand Down Expand Up @@ -372,8 +373,13 @@ def _resolve_project(project_in_option: Optional[str]) -> str:
if project_in_option:
return project_in_option

if IS_WINDOWS:
gcloud_cmd = 'gcloud.cmd'
else:
gcloud_cmd = 'gcloud'

result = subprocess.run(
['gcloud', 'config', 'get-value', 'project'],
[gcloud_cmd, 'config', 'get-value', 'project'],
check=True,
capture_output=True,
text=True,
Expand Down Expand Up @@ -578,9 +584,14 @@ def to_cloud_run(
# Validate that extra gcloud args don't conflict with ADK-managed args
_validate_gcloud_extra_args(extra_gcloud_args, adk_managed_args)

if IS_WINDOWS:
gcloud = 'gcloud.cmd'
else:
gcloud = 'gcloud'

# Build the command with extra gcloud args
gcloud_cmd = [
'gcloud',
gcloud,
'run',
'deploy',
service_name,
Expand Down
8 changes: 7 additions & 1 deletion tests/unittests/cli/utils/test_cli_deploy_to_cloud_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import shutil
import subprocess
import tempfile
import os
from typing import Any
from typing import Dict
from typing import List
Expand Down Expand Up @@ -172,8 +173,13 @@ def test_to_cloud_run_happy_path(
assert len(run_recorder.calls) == 1
gcloud_args = run_recorder.get_last_call_args()[0]

if os.name == "nt":
gcloud_cmd = "gcloud.cmd"
else:
gcloud_cmd = "gcloud"

expected_gcloud_command = [
"gcloud",
gcloud_cmd,
"run",
"deploy",
"svc",
Expand Down