Skip to content

Add VCS root management commands #170

@tiulpin

Description

@tiulpin

Area: VCS Operations (remote run, changes)

Problem or use case

The CLI has no commands for managing VCS roots. The API client only has a read method (GetVcsRootEntries) — no create, update, or delete. AI agents following Journey 2 (set up CI via agent) need to connect a repository to TeamCity as a core step, but currently must use raw API calls with complex payloads:

# Current workaround — extremely agent-unfriendly
teamcity api '/app/rest/vcs-roots' -X POST --input vcs-root.json

The VCS root JSON payload is complex (auth type, branch spec, URL, etc.), making it one of the hardest things for an agent to get right via raw API.

Proposed solution

CLI commands

teamcity vcs list                                         # List all VCS roots
teamcity vcs list --project <id>                          # Filter by project
teamcity vcs view <id>                                    # View VCS root details
teamcity vcs create <name> --project <id> --url <repo>    # Create from repo URL
teamcity vcs delete <id>                                  # Delete VCS root

Smart defaults for vcs create

# Minimal — auto-detect VCS type from URL, use default branch
teamcity vcs create "GitHub Repo" --project MyProject --url https://github.com/org/repo.git

# With auth token
teamcity vcs create "GitHub Repo" --project MyProject --url https://github.com/org/repo.git --token ghp_xxx

# SSH
teamcity vcs create "GitHub Repo" --project MyProject --url git@github.com:org/repo.git --key ~/.ssh/id_ed25519

# With branch spec
teamcity vcs create "GitHub Repo" --project MyProject --url https://github.com/org/repo.git --branch-spec "+:refs/heads/*"

Output:

✓ Created VCS root "GitHub Repo" (id: MyProject_GitHubRepo)
  Type:   git
  URL:    https://github.com/org/repo.git
  Branch: refs/heads/main

Flags for vcs create

  • --project, -p (required) — parent project ID
  • --url (required) — repository URL
  • --id — explicit VCS root ID
  • --branch — default branch (default: refs/heads/main)
  • --branch-spec — branch specification for monitoring
  • --token — auth token (stored as secure token)
  • --key — path to SSH private key
  • --json — machine-readable output

API client additions needed

// New methods for api/interface.go
GetVcsRoots(opts VcsRootsOptions) (*VcsRootList, error)
GetVcsRoot(id string) (*VcsRoot, error)
CreateVcsRoot(req CreateVcsRootRequest) (*VcsRoot, error)
DeleteVcsRoot(id string) error

REST endpoints:

GET    /app/rest/vcs-roots
GET    /app/rest/vcs-roots/id:<id>
POST   /app/rest/vcs-roots
DELETE /app/rest/vcs-roots/id:<id>

Alternatives considered

  • Only expose via teamcity api raw endpoint — payload is too complex for agents to construct reliably
  • Auto-create VCS root as part of job create — could work as a convenience, but VCS roots are project-level resources shared across jobs; they need independent management
  • Attach VCS root to job inline: teamcity job create ... --vcs-url <url> — useful sugar, but separate VCS root management is still needed

Contribution

  • I'd be willing to submit a PR for this feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vcsVCS operations (remote run, pre-tested commit, changes)enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions