| iomodo | 578f504 | 2025-07-28 20:46:02 +0400 | [diff] [blame] | 1 | # Gerrit Integration Guide |
| 2 | |
| 3 | Staff AI Agent System now supports Gerrit as an alternative to GitHub for pull request management. This guide explains how to configure and use Gerrit with Staff. |
| 4 | |
| 5 | ## Overview |
| 6 | |
| 7 | Gerrit integration provides the same capabilities as GitHub: |
| 8 | - Create changes (Gerrit's equivalent of pull requests) |
| 9 | - List and manage changes |
| 10 | - Update change descriptions |
| 11 | - Close (abandon) changes |
| 12 | - Submit (merge) changes |
| 13 | - Structured logging for all operations |
| 14 | |
| 15 | ## Configuration |
| 16 | |
| 17 | ### YAML Configuration |
| 18 | |
| 19 | Add Gerrit configuration to your `config.yaml`: |
| 20 | |
| 21 | ```yaml |
| 22 | # Either GitHub OR Gerrit is required |
| 23 | gerrit: |
| 24 | username: "your-gerrit-username" |
| 25 | password: "your-gerrit-http-password-or-token" |
| 26 | base_url: "https://gerrit.example.com" |
| 27 | project: "your-project-name" |
| 28 | ``` |
| 29 | |
| 30 | ### Environment Variables |
| 31 | |
| 32 | You can also configure Gerrit using environment variables: |
| 33 | |
| 34 | ```bash |
| 35 | export GERRIT_USERNAME="your-username" |
| 36 | export GERRIT_PASSWORD="your-password-or-token" |
| 37 | export GERRIT_BASE_URL="https://gerrit.example.com" |
| 38 | export GERRIT_PROJECT="your-project" |
| 39 | ``` |
| 40 | |
| 41 | ## Provider Priority |
| 42 | |
| 43 | When both GitHub and Gerrit are configured, GitHub takes precedence for backward compatibility. To use Gerrit when both are configured, remove the GitHub configuration. |
| 44 | |
| 45 | ## Authentication |
| 46 | |
| 47 | Gerrit integration supports: |
| 48 | - **HTTP Password**: Traditional Gerrit HTTP password |
| 49 | - **HTTP Token**: Generate from Gerrit Settings → HTTP Credentials |
| 50 | |
| 51 | ## URL Format |
| 52 | |
| 53 | Generated change URLs follow Gerrit's standard format: |
| 54 | ``` |
| 55 | https://gerrit.example.com/c/project-name/+/12345 |
| 56 | ``` |
| 57 | |
| 58 | ## Agent Behavior |
| 59 | |
| 60 | Agents work identically with Gerrit: |
| 61 | 1. Process assigned tasks |
| 62 | 2. Generate solutions using LLM |
| 63 | 3. Create Git branches and commits |
| 64 | 4. Create Gerrit changes for review |
| 65 | 5. Update task status with change URL |
| 66 | |
| 67 | ## Configuration Validation |
| 68 | |
| 69 | Use the config check command to verify your Gerrit setup: |
| 70 | |
| 71 | ```bash |
| 72 | ./staff config-check |
| 73 | ``` |
| 74 | |
| 75 | This will show: |
| 76 | - Which Git provider is configured (GitHub/Gerrit) |
| 77 | - Validation of all required fields |
| 78 | - Connection status |
| 79 | |
| 80 | ## Example Configuration |
| 81 | |
| 82 | See `config-gerrit-example.yaml` for a complete example configuration using Gerrit instead of GitHub. |
| 83 | |
| 84 | ## Structured Logging |
| 85 | |
| 86 | All Gerrit operations include structured logging: |
| 87 | |
| 88 | ``` |
| 89 | INFO Creating Gerrit change url=https://gerrit.example.com/a/changes/ project=my-project subject="Task ABC-123: Implement feature" branch=main topic=task/ABC-123-implement-feature |
| 90 | ``` |
| 91 | |
| 92 | ## Comparison with GitHub |
| 93 | |
| 94 | | Feature | GitHub | Gerrit | |
| 95 | |---------|--------|--------| |
| 96 | | Changes/PRs | Pull Requests | Changes | |
| 97 | | Review System | GitHub Reviews | Gerrit Code Review | |
| 98 | | Merge | Merge PR | Submit Change | |
| 99 | | Close | Close PR | Abandon Change | |
| 100 | | URL Format | `/pull/123` | `/c/project/+/123` | |
| 101 | | Authentication | Token | Username + Password/Token | |
| 102 | |
| 103 | ## Migration |
| 104 | |
| 105 | To migrate from GitHub to Gerrit: |
| 106 | |
| 107 | 1. Update configuration file or environment variables |
| 108 | 2. Remove GitHub configuration |
| 109 | 3. Restart the Staff system |
| 110 | 4. All new agent operations will use Gerrit |
| 111 | |
| 112 | Existing GitHub pull requests are not affected and remain accessible. |
| 113 | |
| 114 | ## Troubleshooting |
| 115 | |
| 116 | ### Common Issues |
| 117 | |
| 118 | 1. **Authentication Failed** |
| 119 | - Verify username and password/token |
| 120 | - Check Gerrit HTTP credentials settings |
| 121 | - Ensure HTTP authentication is enabled |
| 122 | |
| 123 | 2. **Project Not Found** |
| 124 | - Verify project name matches exactly |
| 125 | - Check user has access to the project |
| 126 | - Ensure project exists in Gerrit |
| 127 | |
| 128 | 3. **Network Issues** |
| 129 | - Verify base URL is correct and accessible |
| 130 | - Check firewall/proxy settings |
| 131 | - Test connectivity to Gerrit server |
| 132 | |
| 133 | ### Debug Logging |
| 134 | |
| 135 | Enable debug logging to troubleshoot issues: |
| 136 | |
| 137 | ```yaml |
| 138 | # Add to your configuration |
| 139 | logging: |
| 140 | level: debug |
| 141 | ``` |
| 142 | |
| 143 | This will show detailed HTTP requests and responses for Gerrit operations. |