Skip to content

Conversation

@kotaitos
Copy link
Contributor

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

Problem:
The adk deploy commands (cloud_run, agent_engine, gke) were not properly respecting .gitignore, .gcloudignore, or .ae_ignore files. This caused all files in the source directory, including large or sensitive ones like venv/, .git/, and .env, to be copied to the temporary staging directory and subsequently uploaded to hosted environments.

Solution:

  • Implemented a unified _get_ignore_patterns_func helper in src/google/adk/cli/cli_deploy.py that reads and combines patterns from .gitignore, .gcloudignore, and .ae_ignore.
  • Updated to_cloud_run, to_agent_engine, and to_gke to use this helper as an ignore filter in shutil.copytree.
  • This ensures that only the files intended by the user are staged and deployed.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Summary of pytest results:

tests/unittests/cli/utils/test_cli_deploy_ignore.py ... [100%]
3 passed in 2.20s

Manual End-to-End (E2E) Tests:

Verified the fix by following these steps:

  1. Setup: Created a dummy agent directory with a .gitignore file.
    mkdir -p verify_agent
    touch verify_agent/agent.py verify_agent/__init__.py
    touch verify_agent/ignored_file.txt
    echo "ignored_file.txt" > verify_agent/.gitignore
  2. Execution: Ran the deploy command pointing to a local temp folder.
    adk deploy cloud_run --temp_folder ./debug_staged_out ./verify_agent
  3. Verification: Temporarily disabled the shutil.rmtree cleanup in code to inspect ./debug_staged_out.
  4. Result: Confirmed that agent.py and .gitignore were present, but ignored_file.txt was correctly excluded from the staging area.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

The adk deploy commands (cloud_run, agent_engine, gke) were not properly
respecting .gitignore, .gcloudignore, or .ae_ignore files, causing
unwanted files (like venv, .git, etc.) to be uploaded.

This change:
- Adds a unified _get_ignore_patterns_func helper that reads all three ignore files.
- Updates to_cloud_run, to_agent_engine, and to_gke to use this helper.
- Removes hardcoded ignore patterns to strictly follow user configuration.
- Adds comprehensive unit tests to verify the fix.

Fixes google#4183
@gemini-code-assist
Copy link
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@adk-bot adk-bot added the tools [Component] This issue is related to tools label Jan 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

adk deploy cloud_run does not respect .gitignore or .gcloudignore

2 participants