|
| 1 | +# qodev-gitlab-cli |
| 2 | + |
| 3 | +Agent-friendly CLI for the GitLab API. Designed for both human and AI-agent workflows, with structured JSON output, consistent flags, and predictable error codes. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +```bash |
| 8 | +pip install qodev-gitlab-cli |
| 9 | +``` |
| 10 | + |
| 11 | +Or run directly without installing: |
| 12 | + |
| 13 | +```bash |
| 14 | +uvx qodev-gitlab-cli |
| 15 | +``` |
| 16 | + |
| 17 | +## Quick Start |
| 18 | + |
| 19 | +```bash |
| 20 | +# Set your GitLab token |
| 21 | +export GITLAB_TOKEN="glpat-xxxxxxxxxxxxxxxxxxxx" |
| 22 | + |
| 23 | +# List open merge requests for a project |
| 24 | +qodev-gitlab mrs list --project mygroup/myproject |
| 25 | + |
| 26 | +# Get details of a specific issue |
| 27 | +qodev-gitlab issues get 42 --project mygroup/myproject |
| 28 | + |
| 29 | +# List pipelines, output as JSON for scripting |
| 30 | +qodev-gitlab pipelines list --project mygroup/myproject --json |
| 31 | + |
| 32 | +# Create a merge request from the current branch |
| 33 | +qodev-gitlab mrs create --title "Add new feature" --project mygroup/myproject |
| 34 | +``` |
| 35 | + |
| 36 | +## Commands |
| 37 | + |
| 38 | +| Group | Subcommand | Description | |
| 39 | +|---|---|---| |
| 40 | +| **projects** | `list` | List projects (`--owned` for owned only) | |
| 41 | +| | `get` | Get project details | |
| 42 | +| **mrs** | `list` | List merge requests (`--state`) | |
| 43 | +| | `get` | Get merge request details | |
| 44 | +| | `create` | Create a merge request (`--title`, `--source`, `--target`, `--description`, `--labels`, `--squash`) | |
| 45 | +| | `update` | Update a merge request (`--title`, `--description`, `--labels`, `--target`) | |
| 46 | +| | `merge` | Merge a merge request (`--squash`, `--when-pipeline-succeeds`) | |
| 47 | +| | `close` | Close a merge request | |
| 48 | +| | `discussions` | List discussions on a merge request | |
| 49 | +| | `changes` | Show diff for a merge request | |
| 50 | +| | `commits` | List commits in a merge request | |
| 51 | +| | `approvals` | Show approval status | |
| 52 | +| | `comment` | Comment on a merge request (`--body`) | |
| 53 | +| | `pipelines` | List pipelines for a merge request | |
| 54 | +| **pipelines** | `list` | List pipelines (`--ref`, `--limit`) | |
| 55 | +| | `get` | Get pipeline details | |
| 56 | +| | `jobs` | List jobs for a pipeline | |
| 57 | +| | `wait` | Wait for a pipeline to complete (`--timeout`, `--interval`) | |
| 58 | +| **jobs** | `get` | Get job details | |
| 59 | +| | `log` | Get job log output | |
| 60 | +| | `retry` | Retry a failed job | |
| 61 | +| **issues** | `list` | List issues (`--state`, `--labels`, `--milestone`) | |
| 62 | +| | `get` | Get issue details | |
| 63 | +| | `create` | Create an issue (`--title`, `--description`, `--labels`) | |
| 64 | +| | `update` | Update an issue (`--title`, `--description`, `--labels`) | |
| 65 | +| | `close` | Close an issue | |
| 66 | +| | `comment` | Comment on an issue (`--body`) | |
| 67 | +| | `notes` | List comments/notes on an issue | |
| 68 | +| **releases** | `list` | List releases | |
| 69 | +| | `get` | Get release details by tag | |
| 70 | +| | `create` | Create a release (`--tag`, `--name`, `--description`, `--ref`) | |
| 71 | +| **variables** | `list` | List CI/CD variables (values hidden) | |
| 72 | +| | `get` | Get a CI/CD variable | |
| 73 | +| | `set` | Set (create or update) a CI/CD variable (`--protected`, `--masked`) | |
| 74 | + |
| 75 | +## Configuration |
| 76 | + |
| 77 | +### Authentication |
| 78 | + |
| 79 | +Set the `GITLAB_TOKEN` environment variable, or pass `--token` on each invocation: |
| 80 | + |
| 81 | +```bash |
| 82 | +export GITLAB_TOKEN="glpat-xxxxxxxxxxxxxxxxxxxx" |
| 83 | +``` |
| 84 | + |
| 85 | +### GitLab Instance |
| 86 | + |
| 87 | +By default the CLI targets `https://gitlab.com`. Override with the `GITLAB_URL` environment variable or the `--url` flag: |
| 88 | + |
| 89 | +```bash |
| 90 | +export GITLAB_URL="https://gitlab.example.com" |
| 91 | +``` |
| 92 | + |
| 93 | +### Global Options |
| 94 | + |
| 95 | +| Flag | Description | Default | |
| 96 | +|---|---|---| |
| 97 | +| `--json` | Output as JSON (for scripting / agents) | `false` | |
| 98 | +| `--project`, `-p` | Project ID or path | auto-detected from git remote | |
| 99 | +| `--limit` | Results per page | `25` | |
| 100 | +| `--page` | Page number | `1` | |
| 101 | +| `--token` | GitLab token (overrides `GITLAB_TOKEN`) | | |
| 102 | +| `--url` | GitLab URL (overrides `GITLAB_URL`) | | |
| 103 | + |
| 104 | +### Exit Codes |
| 105 | + |
| 106 | +| Code | Meaning | |
| 107 | +|---|---| |
| 108 | +| `0` | Success | |
| 109 | +| `80` | Authentication error | |
| 110 | +| `81` | Not found | |
| 111 | +| `82` | API error | |
| 112 | +| `83` | Validation error | |
| 113 | +| `84` | Configuration error | |
| 114 | + |
| 115 | +## License |
| 116 | + |
| 117 | +MIT -- see [LICENSE](LICENSE) for details. |
0 commit comments