package module
Version: v0.0.0-...-2dcf0ae Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2017 License: MIT Imports: 7 Imported by: 1



TeamCity API client for Golang



  • Supports both guest and basic authorization
  • Provides read-only access to TeamCity REST API
  • This library is totally not feature-complete so far


Please have a look at the GoDoc documentation for a detailed API description.


package main

import (

func main() {
  tcClient := teamcity.NewClient("", teamcity.GuestAuth())
  projects, err := tcClient.GetProjects()
  if err != nil {
  fmt.Printf("List of projects:\n")
  for _, project := range projects {
    fmt.Printf(" * %s\n", project.ID)




This section is empty.


This section is empty.


This section is empty.


type Authorizer

type Authorizer interface {
	// ResolveUrl provides a full absolute root URL.
	// It should use the following format: baseURL + PREFIX.
	// PREFIX might be either "/guestAuth/app/rest" or "/httpAuth/app/rest" depending on authorization mode.
	ResolveBaseURL(baseURL string) string

	// GetUserInfo provides credentials for HTTP basic auth.
	// It returns nil for guest access mode.
	GetUserInfo() *url.Userinfo

Authorizer is a TeamCity client authorizer

func BasicAuth

func BasicAuth(username string, password string) Authorizer

BasicAuth creates an Authorizer for an authorized access (using HTTP Basic Auth)

func GuestAuth

func GuestAuth() Authorizer

GuestAuth creates an Authorizer for non-authorized access

type Build

type Build struct {
	// Build ID
	ID int `json:"id"`
	// Build Number
	Number string `json:"number"`
	// Build Status
	Status BuildStatus `json:"status"`
	// Build Status Text
	StatusText string `json:"statusText"`
	// Build Progress Percentage
	Progress int `json:"progress"`
	// Build type ID
	BuildTypeID string `json:"buildTypeId"`

Build is a TeamCity project build

type BuildStatus

type BuildStatus int

BuildStatus is a build status enum

const (
	// StatusUnknown is a zero value of BuildStatus
	StatusUnknown BuildStatus = iota

	// StatusSuccess is a status of successful build

	// StatusRunning is a status of build that is currently running

	// StatusFailure is a status of failed build

type BuildType

type BuildType struct {
	// Project ID
	ID string `json:"id"`
	// Project name
	Name string `json:"name"`
	// Project description
	Description string `json:"description"`
	// Project ID
	ProjectID string `json:"projectId"`

BuildType is a TeamCity project build configuration

type Change

type Change struct {
	// Change ID
	ID int `json:"id"`
	// VCS revision id
	Version string `json:"version"`
	// Change author username
	Username string `json:"username"`
	// Change date
	Date string `json:"date"`

Change is a TeamCity project change

type Client

type Client interface {
	// Get a project by its ID
	GetProjectByID(id string) (Project, error)
	// Get a project by its name
	GetProjectByName(name string) (Project, error)
	// Get list of projects
	GetProjects() ([]Project, error)

	// Get build type by its ID
	GetBuildTypeByID(id string) (BuildType, error)
	// Get list of all build types
	GetBuildTypes() ([]BuildType, error)
	// Get list of build types for a project
	GetBuildTypesForProject(id string) ([]BuildType, error)

	// Get build by its ID
	GetBuildByID(id int) (Build, error)
	// Get N latest builds
	GetBuilds(count int) ([]Build, error)
	// Get N latest builds for a build type
	GetBuildsForBuildType(id string, count int) ([]Build, error)

	// Get change by its ID
	GetChangeByID(id int) (Change, error)
	// Get N latest changes
	GetChanges(count int) ([]Change, error)
	// Get N latest changes for a project
	GetChangesForProject(id string, count int) ([]Change, error)
	// Get changes for a build
	GetChangesForBuild(id int) ([]Change, error)
	// Get changes for build type since a particular change
	GetChangesForBuildTypeSinceChange(btId string, cId int) ([]Change, error)
	// Get pending changes for build type
	GetChangesForBuildTypePending(id string) ([]Change, error)

Client is a TeamCity client

func NewClient

func NewClient(url string, auth Authorizer) Client

NewClient creates new TeamCity Client

type Project

type Project struct {
	// Project ID
	ID string `json:"id"`
	// Project name
	Name string `json:"name"`
	// Project description
	Description string `json:"description"`
	// Parent project ID
	ParentProjectID string `json:"parentProjectId"`

Project is a TeamCity project

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL