Documentation
¶
Index ¶
- Constants
- Variables
- func FormatTeamCityTime(t time.Time) string
- func ParseTeamCityTime(s string) (time.Time, error)
- func ParseUserDate(input string) (string, error)
- func ToAPIFields(fields []string) string
- func ToAPIFieldsEncoded(fields []string) string
- type APIError
- type APIErrorResponse
- type Agent
- type AgentList
- type AgentRef
- type AgentsOptions
- type ApprovalInfo
- type Artifact
- type Artifacts
- type Build
- type BuildComment
- type BuildList
- type BuildQueue
- type BuildStep
- type BuildType
- type BuildTypeList
- type BuildTypeRef
- type BuildTypesOptions
- type BuildsOptions
- type Change
- type ChangeList
- type Client
- func (c *Client) AddBuildTags(buildID string, tags []string) error
- func (c *Client) AddProjectToPool(poolID int, projectID string) error
- func (c *Client) ApproveQueuedBuild(buildID string) error
- func (c *Client) AuthorizeAgent(id int, authorized bool) error
- func (c *Client) BuildTypeExists(id string) bool
- func (c *Client) CancelBuild(buildID string, comment string) error
- func (c *Client) CheckVersion() error
- func (c *Client) CreateAPIToken(name string) (*Token, error)
- func (c *Client) CreateBuildStep(buildTypeID string, step BuildStep) error
- func (c *Client) CreateBuildType(projectID string, req CreateBuildTypeRequest) (*BuildType, error)
- func (c *Client) CreateProject(req CreateProjectRequest) (*Project, error)
- func (c *Client) CreateSecureToken(projectID, value string) (string, error)
- func (c *Client) CreateUser(req CreateUserRequest) (*User, error)
- func (c *Client) DeleteAPIToken(name string) error
- func (c *Client) DeleteBuildComment(buildID string) error
- func (c *Client) DeleteBuildTypeParameter(buildTypeID, name string) error
- func (c *Client) DeleteProjectParameter(projectID, name string) error
- func (c *Client) DownloadArtifact(buildID, artifactPath string) ([]byte, error)
- func (c *Client) DownloadArtifactTo(ctx context.Context, buildID, artifactPath string, w io.Writer) (int64, error)
- func (c *Client) EnableAgent(id int, enabled bool) error
- func (c *Client) ExportProjectSettings(projectID, format string, useRelativeIds bool) ([]byte, error)
- func (c *Client) GetAgent(id int) (*Agent, error)
- func (c *Client) GetAgentByName(name string) (*Agent, error)
- func (c *Client) GetAgentCompatibleBuildTypes(id int) (*BuildTypeList, error)
- func (c *Client) GetAgentIncompatibleBuildTypes(id int) (*CompatibilityList, error)
- func (c *Client) GetAgentPool(id int) (*Pool, error)
- func (c *Client) GetAgentPools(requestedFields []string) (*PoolList, error)
- func (c *Client) GetAgents(opts AgentsOptions) (*AgentList, error)
- func (c *Client) GetArtifacts(buildID string) (*Artifacts, error)
- func (c *Client) GetBuild(ref string) (*Build, error)
- func (c *Client) GetBuildChanges(buildID string) (*ChangeList, error)
- func (c *Client) GetBuildComment(buildID string) (string, error)
- func (c *Client) GetBuildLog(buildID string) (string, error)
- func (c *Client) GetBuildProblems(buildID string) (*ProblemOccurrences, error)
- func (c *Client) GetBuildQueue(opts QueueOptions) (*BuildQueue, error)
- func (c *Client) GetBuildTags(buildID string) (*TagList, error)
- func (c *Client) GetBuildTests(buildID string, failedOnly bool, limit int) (*TestOccurrences, error)
- func (c *Client) GetBuildType(id string) (*BuildType, error)
- func (c *Client) GetBuildTypeParameter(buildTypeID, name string) (*Parameter, error)
- func (c *Client) GetBuildTypeParameters(buildTypeID string) (*ParameterList, error)
- func (c *Client) GetBuildTypes(opts BuildTypesOptions) (*BuildTypeList, error)
- func (c *Client) GetBuilds(opts BuildsOptions) (*BuildList, error)
- func (c *Client) GetCurrentUser() (*User, error)
- func (c *Client) GetParameterValue(path string) (string, error)
- func (c *Client) GetProject(id string) (*Project, error)
- func (c *Client) GetProjectParameter(projectID, name string) (*Parameter, error)
- func (c *Client) GetProjectParameters(projectID string) (*ParameterList, error)
- func (c *Client) GetProjects(opts ProjectsOptions) (*ProjectList, error)
- func (c *Client) GetQueuedBuildApprovalInfo(buildID string) (*ApprovalInfo, error)
- func (c *Client) GetSecureValue(projectID, token string) (string, error)
- func (c *Client) GetServer() (*Server, error)
- func (c *Client) GetUser(username string) (*User, error)
- func (c *Client) GetVcsRootEntries(buildTypeID string) (*VcsRootEntries, error)
- func (c *Client) GetVersionedSettingsConfig(projectID string) (*VersionedSettingsConfig, error)
- func (c *Client) GetVersionedSettingsStatus(projectID string) (*VersionedSettingsStatus, error)
- func (c *Client) MoveQueuedBuildToTop(buildID string) error
- func (c *Client) PinBuild(buildID string, comment string) error
- func (c *Client) ProjectExists(id string) bool
- func (c *Client) RawRequest(method, path string, body io.Reader, headers map[string]string) (*RawResponse, error)
- func (c *Client) RebootAgent(ctx context.Context, id int, afterBuild bool) error
- func (c *Client) RemoveBuildTag(buildID string, tag string) error
- func (c *Client) RemoveFromQueue(id string) error
- func (c *Client) RemoveProjectFromPool(poolID int, projectID string) error
- func (c *Client) ResolveBuildID(ref string) (string, error)
- func (c *Client) RunBuild(buildTypeID string, opts RunBuildOptions) (*Build, error)
- func (c *Client) ServerVersion() (*Server, error)
- func (c *Client) SetAgentPool(agentID int, poolID int) error
- func (c *Client) SetBuildComment(buildID string, comment string) error
- func (c *Client) SetBuildTypeParameter(buildTypeID, name, value string, secure bool) error
- func (c *Client) SetBuildTypePaused(id string, paused bool) error
- func (c *Client) SetBuildTypeSetting(buildTypeID, setting, value string) error
- func (c *Client) SetProjectParameter(projectID, name, value string, secure bool) error
- func (c *Client) SetQueuedBuildPosition(buildID string, position int) error
- func (c *Client) SupportsFeature(feature string) bool
- func (c *Client) UnpinBuild(buildID string) error
- func (c *Client) UploadDiffChanges(patch []byte, description string) (string, error)
- func (c *Client) UserExists(username string) bool
- type ClientInterface
- type ClientOption
- type Compatibility
- type CompatibilityList
- type Content
- type CreateBuildTypeRequest
- type CreateProjectRequest
- type CreateUserRequest
- type FieldSpec
- type FileChange
- type Files
- type IncompatibleReasons
- type LastChanges
- type Locator
- func (l *Locator) Add(key, value string) *Locator
- func (l *Locator) AddInt(key string, value int) *Locator
- func (l *Locator) AddIntDefault(key string, value, defaultVal int) *Locator
- func (l *Locator) AddRaw(key, value string) *Locator
- func (l *Locator) AddUpper(key, value string) *Locator
- func (l *Locator) Encode() string
- func (l *Locator) IsEmpty() bool
- func (l *Locator) String() string
- type Parameter
- type ParameterList
- type ParameterType
- type PersonalChange
- type Pool
- type PoolList
- type ProblemOccurrence
- type ProblemOccurrences
- type Project
- type ProjectList
- type ProjectsOptions
- type Property
- type PropertyList
- type QueueOptions
- type QueuedBuild
- type RawResponse
- type RetryConfig
- type Revision
- type Revisions
- type Role
- type RoleList
- type RunBuildOptions
- type Server
- type Tag
- type TagList
- type TerminalClient
- type TerminalConn
- type TerminalSession
- type TestOccurrence
- type TestOccurrences
- type Token
- type TriggerBuildRequest
- type Triggered
- type TriggeringOptions
- type User
- type VcsRootEntries
- type VcsRootEntry
- type VcsRootInstanceRef
- type VcsRootRef
- type VersionedSettingsConfig
- type VersionedSettingsStatus
Constants ¶
const ( MinMajorVersion = 2020 MinMinorVersion = 1 )
Minimum supported TeamCity version
Variables ¶
var ( // ReadRetry is the default for idempotent read operations (GET). // Retries on network errors and 5xx responses. ReadRetry = RetryConfig{MaxRetries: 3, Interval: 200 * time.Millisecond} // NoRetry disables retries. Use for non-idempotent operations (POST to queue, etc.). NoRetry = RetryConfig{MaxRetries: 0} // LongRetry is for operations that may need more time to succeed // (e.g., waiting for resources to propagate). LongRetry = RetryConfig{MaxRetries: 3, Interval: 1 * time.Second} )
Predefined retry configurations for different operation types.
var AgentFields = FieldSpec{ Available: []string{"id", "name", "typeId", "connected", "enabled", "authorized", "href", "webUrl", "pool.id", "pool.name"}, Default: []string{"id", "name", "connected", "enabled", "authorized", "href", "webUrl", "pool.id", "pool.name"}, }
var BuildFields = FieldSpec{ Available: []string{ "id", "number", "status", "state", "href", "webUrl", "branchName", "defaultBranch", "buildTypeId", "statusText", "queuedDate", "startDate", "finishDate", "percentageComplete", "pinned", "tags.tag.name", "buildType.id", "buildType.name", "buildType.projectName", "buildType.projectId", "buildType.href", "buildType.webUrl", "triggered.type", "triggered.date", "triggered.user.name", "triggered.user.username", "agent.id", "agent.name", "agent.href", "agent.webUrl", }, Default: []string{ "id", "number", "status", "state", "branchName", "buildTypeId", "buildType.id", "buildType.name", "buildType.projectName", "triggered.type", "triggered.user.name", "triggered.user.username", "startDate", "finishDate", "queuedDate", "agent.name", }, }
BuildFields field specifications
var BuildTypeFields = FieldSpec{ Available: []string{"id", "name", "projectName", "projectId", "href", "webUrl", "paused"}, Default: []string{"id", "name", "projectName", "projectId", "href", "webUrl", "paused"}, }
var PoolFields = FieldSpec{ Available: []string{"id", "name", "maxAgents", "href"}, Default: []string{"id", "name", "maxAgents"}, }
var ProjectFields = FieldSpec{ Available: []string{"id", "name", "description", "parentProjectId", "href", "webUrl"}, Default: []string{"id", "name", "description", "parentProjectId", "href", "webUrl"}, }
var QueuedBuildFields = FieldSpec{ Available: []string{ "id", "buildTypeId", "state", "branchName", "href", "webUrl", "queuedDate", "buildType.id", "buildType.name", "buildType.projectName", "triggered.type", "triggered.date", "triggered.user.name", "triggered.user.username", }, Default: []string{ "id", "buildTypeId", "state", "branchName", "href", "webUrl", "queuedDate", "buildType.id", "buildType.name", "buildType.projectName", "triggered.type", "triggered.user.name", "triggered.user.username", }, }
Functions ¶
func FormatTeamCityTime ¶
FormatTeamCityTime formats time to TeamCity's date format.
func ParseTeamCityTime ¶
ParseTeamCityTime parses TeamCity's time format (20250710T080607+0000)
func ParseUserDate ¶
ParseUserDate converts user input to TeamCity date format. Supports: "24h" (relative), "2026-01-21" (absolute), or TeamCity format.
func ToAPIFields ¶
ToAPIFields converts dot-notation fields to TeamCity API fields parameter. Example: ["id", "buildType.name", "buildType.projectId"] -> "id,buildType(name,projectId)"
func ToAPIFieldsEncoded ¶
ToAPIFieldsEncoded returns URL-encoded TeamCity API fields parameter
Types ¶
type APIError ¶
type APIError struct {
Message string `json:"message"`
}
APIError represents an error from TeamCity's REST API
type APIErrorResponse ¶
type APIErrorResponse struct {
Errors []APIError `json:"errors"`
}
APIErrorResponse represents TeamCity's error response format
type Agent ¶
type Agent struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
TypeID int `json:"typeId,omitempty"`
Connected bool `json:"connected,omitempty"`
Enabled bool `json:"enabled,omitempty"`
Authorized bool `json:"authorized,omitempty"`
Href string `json:"href,omitempty"`
WebURL string `json:"webUrl,omitempty"`
Pool *Pool `json:"pool,omitempty"`
Build *Build `json:"build,omitempty"`
}
Agent represents a build agent
type AgentList ¶
type AgentList struct {
Count int `json:"count"`
Href string `json:"href"`
NextHref string `json:"nextHref,omitempty"`
Agents []Agent `json:"agent"`
}
AgentList represents a list of agents
type AgentsOptions ¶
type AgentsOptions struct {
Authorized bool // Filter by authorization status
Connected bool // Filter by connection status
Enabled bool // Filter by enabled status
Pool string // Filter by pool name
Limit int
Fields []string // Fields to return (uses AgentFields.Default if empty)
}
AgentsOptions represents options for listing agents
type ApprovalInfo ¶
type ApprovalInfo struct {
Status string `json:"status"`
ConfigurationValid bool `json:"configurationValid"`
CanBeApprovedByCurrentUser bool `json:"canBeApprovedByCurrentUser"`
}
ApprovalInfo represents approval information for a queued build
type Artifact ¶
type Artifact struct {
Name string `json:"name"`
Size int64 `json:"size,omitempty"`
ModTime string `json:"modificationTime,omitempty"`
Href string `json:"href,omitempty"`
Children *Artifacts `json:"children,omitempty"`
Content *Content `json:"content,omitempty"`
}
Artifact represents a build artifact
type Build ¶
type Build struct {
ID int `json:"id"`
BuildTypeID string `json:"buildTypeId,omitempty"`
Number string `json:"number,omitempty"`
Status string `json:"status,omitempty"`
State string `json:"state,omitempty"`
Personal bool `json:"personal,omitempty"`
BranchName string `json:"branchName,omitempty"`
DefaultBranch bool `json:"defaultBranch,omitempty"`
Href string `json:"href,omitempty"`
WebURL string `json:"webUrl,omitempty"`
StatusText string `json:"statusText,omitempty"`
QueuedDate string `json:"queuedDate,omitempty"`
StartDate string `json:"startDate,omitempty"`
FinishDate string `json:"finishDate,omitempty"`
BuildType *BuildType `json:"buildType,omitempty"`
Triggered *Triggered `json:"triggered,omitempty"`
Agent *Agent `json:"agent,omitempty"`
PercentageComplete int `json:"percentageComplete,omitempty"`
Pinned bool `json:"pinned,omitempty"`
Tags *TagList `json:"tags,omitempty"`
LastChanges *ChangeList `json:"lastChanges,omitempty"`
}
Build represents a TeamCity build
type BuildComment ¶
type BuildComment struct {
Text string `json:"text"`
}
BuildComment represents a comment on a build
type BuildList ¶
type BuildList struct {
Count int `json:"count"`
Href string `json:"href"`
NextHref string `json:"nextHref,omitempty"`
Builds []Build `json:"build"`
}
BuildList represents a list of builds
type BuildQueue ¶
type BuildQueue struct {
Count int `json:"count"`
Href string `json:"href"`
Builds []QueuedBuild `json:"build"`
}
BuildQueue represents the build queue
type BuildStep ¶
type BuildStep struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
Type string `json:"type"`
Properties PropertyList `json:"properties,omitempty"`
}
BuildStep represents a build step configuration
type BuildType ¶
type BuildType struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
ProjectName string `json:"projectName,omitempty"`
ProjectID string `json:"projectId,omitempty"`
Href string `json:"href,omitempty"`
WebURL string `json:"webUrl,omitempty"`
Paused bool `json:"paused,omitempty"`
Project *Project `json:"project,omitempty"`
}
BuildType represents a build configuration
type BuildTypeList ¶
BuildTypeList represents a list of build configurations
type BuildTypeRef ¶
type BuildTypeRef struct {
ID string `json:"id"`
}
BuildTypeRef is a reference to a build type
type BuildTypesOptions ¶
BuildTypesOptions represents options for listing build configurations
type BuildsOptions ¶
type BuildsOptions struct {
BuildTypeID string
Branch string
Status string
State string
User string
Project string
Number string
Limit int
SinceDate string
UntilDate string
Fields []string
}
BuildsOptions represents options for listing builds
type Change ¶
type Change struct {
ID int `json:"id,omitempty"`
Version string `json:"version,omitempty"` // commit SHA
Username string `json:"username,omitempty"`
Date string `json:"date,omitempty"`
Comment string `json:"comment,omitempty"`
WebURL string `json:"webUrl,omitempty"`
Files *Files `json:"files,omitempty"`
}
type ChangeList ¶
type Client ¶
type Client struct {
BaseURL string
Token string
APIVersion string // Optional: pin to a specific API version (e.g., "2020.1")
HTTPClient *http.Client
// contains filtered or unexported fields
}
Client represents a TeamCity API client
func NewClient ¶
func NewClient(baseURL, token string, opts ...ClientOption) *Client
NewClient creates a new TeamCity API client with Bearer token authentication
func NewClientWithBasicAuth ¶
func NewClientWithBasicAuth(baseURL, username, password string, opts ...ClientOption) *Client
NewClientWithBasicAuth creates a new TeamCity API client with Basic authentication. Use empty username with superuser token, or username/password for regular users.
func (*Client) AddBuildTags ¶
AddBuildTags adds tags to a build (accepts ID or #number)
func (*Client) AddProjectToPool ¶ added in v0.2.0
AddProjectToPool assigns a project to an agent pool
func (*Client) ApproveQueuedBuild ¶
ApproveQueuedBuild approves a queued build that requires approval
func (*Client) AuthorizeAgent ¶
AuthorizeAgent sets the authorized status of an agent
func (*Client) BuildTypeExists ¶
BuildTypeExists checks if a build configuration exists
func (*Client) CancelBuild ¶
CancelBuild cancels a running or queued build (accepts ID or #number)
func (*Client) CheckVersion ¶
CheckVersion verifies the server meets minimum version requirements
func (*Client) CreateAPIToken ¶
CreateAPIToken creates an API token for the current user
func (*Client) CreateBuildStep ¶
CreateBuildStep adds a build step to a build configuration
func (*Client) CreateBuildType ¶
func (c *Client) CreateBuildType(projectID string, req CreateBuildTypeRequest) (*BuildType, error)
CreateBuildType creates a new build configuration in a project
func (*Client) CreateProject ¶
func (c *Client) CreateProject(req CreateProjectRequest) (*Project, error)
CreateProject creates a new project
func (*Client) CreateSecureToken ¶
CreateSecureToken creates a new secure token for the given value in a project. Returns the scrambled token that can be used in configuration files as credentialsJSON:<token>. Requires EDIT_PROJECT permission.
func (*Client) CreateUser ¶
func (c *Client) CreateUser(req CreateUserRequest) (*User, error)
CreateUser creates a new user
func (*Client) DeleteAPIToken ¶
DeleteAPIToken deletes an API token for the current user
func (*Client) DeleteBuildComment ¶
DeleteBuildComment removes the comment from a build (accepts ID or #number)
func (*Client) DeleteBuildTypeParameter ¶
DeleteBuildTypeParameter deletes a parameter from a build configuration
func (*Client) DeleteProjectParameter ¶
DeleteProjectParameter deletes a parameter from a project
func (*Client) DownloadArtifact ¶
DownloadArtifact downloads an artifact and returns its content (accepts ID or #number)
func (*Client) DownloadArtifactTo ¶ added in v0.4.0
func (c *Client) DownloadArtifactTo(ctx context.Context, buildID, artifactPath string, w io.Writer) (int64, error)
DownloadArtifactTo streams an artifact to a writer (accepts ID or #number)
func (*Client) EnableAgent ¶ added in v0.2.0
EnableAgent sets the enabled status of an agent
func (*Client) ExportProjectSettings ¶ added in v0.3.0
func (c *Client) ExportProjectSettings(projectID, format string, useRelativeIds bool) ([]byte, error)
ExportProjectSettings exports project settings as a ZIP archive in the specified format. Format can be "kotlin" or "xml". Returns the raw ZIP file bytes.
func (*Client) GetAgentByName ¶ added in v0.4.0
GetAgentByName returns details for an agent by name. PathEscape is sufficient here: TeamCity prohibits colons and commas in agent names (they conflict with locator syntax), so we only need to escape path-unsafe characters.
func (*Client) GetAgentCompatibleBuildTypes ¶ added in v0.2.0
func (c *Client) GetAgentCompatibleBuildTypes(id int) (*BuildTypeList, error)
GetAgentCompatibleBuildTypes returns build types compatible with an agent
func (*Client) GetAgentIncompatibleBuildTypes ¶ added in v0.2.0
func (c *Client) GetAgentIncompatibleBuildTypes(id int) (*CompatibilityList, error)
GetAgentIncompatibleBuildTypes returns build types incompatible with an agent and reasons
func (*Client) GetAgentPool ¶ added in v0.2.0
GetAgentPool returns details for a single pool
func (*Client) GetAgentPools ¶ added in v0.2.0
GetAgentPools returns all agent pools
func (*Client) GetAgents ¶
func (c *Client) GetAgents(opts AgentsOptions) (*AgentList, error)
GetAgents returns a list of agents
func (*Client) GetArtifacts ¶
GetArtifacts returns the artifacts for a build (accepts ID or #number)
func (*Client) GetBuildChanges ¶
func (c *Client) GetBuildChanges(buildID string) (*ChangeList, error)
func (*Client) GetBuildComment ¶
GetBuildComment returns the comment for a build (accepts ID or #number)
func (*Client) GetBuildLog ¶
GetBuildLog returns the build log (accepts ID or #number)
func (*Client) GetBuildProblems ¶ added in v0.4.0
func (c *Client) GetBuildProblems(buildID string) (*ProblemOccurrences, error)
func (*Client) GetBuildQueue ¶
func (c *Client) GetBuildQueue(opts QueueOptions) (*BuildQueue, error)
GetBuildQueue returns the build queue
func (*Client) GetBuildTags ¶
GetBuildTags returns the tags for a build (accepts ID or #number)
func (*Client) GetBuildTests ¶
func (*Client) GetBuildType ¶
GetBuildType returns a single build configuration by ID
func (*Client) GetBuildTypeParameter ¶
GetBuildTypeParameter returns a specific parameter for a build configuration
func (*Client) GetBuildTypeParameters ¶
func (c *Client) GetBuildTypeParameters(buildTypeID string) (*ParameterList, error)
GetBuildTypeParameters returns parameters for a build configuration
func (*Client) GetBuildTypes ¶
func (c *Client) GetBuildTypes(opts BuildTypesOptions) (*BuildTypeList, error)
GetBuildTypes returns a list of build configurations
func (*Client) GetBuilds ¶
func (c *Client) GetBuilds(opts BuildsOptions) (*BuildList, error)
GetBuilds returns a list of builds
func (*Client) GetCurrentUser ¶
GetCurrentUser returns the authenticated user
func (*Client) GetParameterValue ¶
GetParameterValue returns just the raw value of a parameter
func (*Client) GetProject ¶
GetProject returns a single project by ID
func (*Client) GetProjectParameter ¶
GetProjectParameter returns a specific parameter for a project
func (*Client) GetProjectParameters ¶
func (c *Client) GetProjectParameters(projectID string) (*ParameterList, error)
GetProjectParameters returns parameters for a project
func (*Client) GetProjects ¶
func (c *Client) GetProjects(opts ProjectsOptions) (*ProjectList, error)
GetProjects returns a list of projects
func (*Client) GetQueuedBuildApprovalInfo ¶
func (c *Client) GetQueuedBuildApprovalInfo(buildID string) (*ApprovalInfo, error)
GetQueuedBuildApprovalInfo returns approval information for a queued build
func (*Client) GetSecureValue ¶
GetSecureValue retrieves the original value for a secure token. Requires CHANGE_SERVER_SETTINGS permission (System Administrator only).
func (*Client) GetVcsRootEntries ¶ added in v0.5.0
func (c *Client) GetVcsRootEntries(buildTypeID string) (*VcsRootEntries, error)
GetVcsRootEntries returns the VCS root entries attached to a build configuration
func (*Client) GetVersionedSettingsConfig ¶ added in v0.3.0
func (c *Client) GetVersionedSettingsConfig(projectID string) (*VersionedSettingsConfig, error)
GetVersionedSettingsConfig returns the versioned settings configuration for a project.
func (*Client) GetVersionedSettingsStatus ¶ added in v0.3.0
func (c *Client) GetVersionedSettingsStatus(projectID string) (*VersionedSettingsStatus, error)
GetVersionedSettingsStatus returns the sync status of versioned settings for a project.
func (*Client) MoveQueuedBuildToTop ¶
MoveQueuedBuildToTop moves a queued build to the top of the queue
func (*Client) PinBuild ¶
PinBuild pins a build to prevent it from being cleaned up (accepts ID or #number)
func (*Client) ProjectExists ¶
ProjectExists checks if a project exists
func (*Client) RawRequest ¶
func (c *Client) RawRequest(method, path string, body io.Reader, headers map[string]string) (*RawResponse, error)
RawRequest performs a raw HTTP request and returns the response without parsing
func (*Client) RebootAgent ¶ added in v0.4.0
RebootAgent requests a reboot of the specified agent. If afterBuild is true, the agent will reboot after the current build finishes. This uses the web UI endpoint as there is no REST API for agent reboot.
func (*Client) RemoveBuildTag ¶
RemoveBuildTag removes a specific tag from a build (accepts ID or #number)
func (*Client) RemoveFromQueue ¶
RemoveFromQueue removes a build from the queue
func (*Client) RemoveProjectFromPool ¶ added in v0.2.0
RemoveProjectFromPool removes a project from an agent pool
func (*Client) ResolveBuildID ¶
ResolveBuildID resolves a build reference to an ID. If ref starts with #, it's treated as a build number and looked up. Otherwise it's used as-is (assumed to be an ID).
func (*Client) RunBuild ¶
func (c *Client) RunBuild(buildTypeID string, opts RunBuildOptions) (*Build, error)
RunBuild runs a new build with full options
func (*Client) ServerVersion ¶
ServerVersion returns cached server version info
func (*Client) SetAgentPool ¶ added in v0.2.0
SetAgentPool moves an agent to a different pool
func (*Client) SetBuildComment ¶
SetBuildComment sets or updates the comment on a build (accepts ID or #number)
func (*Client) SetBuildTypeParameter ¶
SetBuildTypeParameter sets a parameter for a build configuration
func (*Client) SetBuildTypePaused ¶
SetBuildTypePaused sets the paused state of a build configuration
func (*Client) SetBuildTypeSetting ¶
SetBuildTypeSetting sets a build configuration setting
func (*Client) SetProjectParameter ¶
SetProjectParameter sets a parameter for a project
func (*Client) SetQueuedBuildPosition ¶
SetQueuedBuildPosition moves a queued build to a specific position in the queue
func (*Client) SupportsFeature ¶
SupportsFeature checks if the server supports a specific feature
func (*Client) UnpinBuild ¶
UnpinBuild removes the pin from a build (accepts ID or #number)
func (*Client) UploadDiffChanges ¶ added in v0.2.0
func (*Client) UserExists ¶
UserExists checks if a user exists
type ClientInterface ¶
type ClientInterface interface {
// Server
GetServer() (*Server, error)
ServerVersion() (*Server, error)
CheckVersion() error
SupportsFeature(feature string) bool
// Users
GetCurrentUser() (*User, error)
GetUser(username string) (*User, error)
UserExists(username string) bool
CreateUser(req CreateUserRequest) (*User, error)
CreateAPIToken(name string) (*Token, error)
DeleteAPIToken(name string) error
// Projects
GetProjects(opts ProjectsOptions) (*ProjectList, error)
GetProject(id string) (*Project, error)
CreateProject(req CreateProjectRequest) (*Project, error)
ProjectExists(id string) bool
CreateSecureToken(projectID, value string) (string, error)
GetSecureValue(projectID, token string) (string, error)
GetVersionedSettingsStatus(projectID string) (*VersionedSettingsStatus, error)
GetVersionedSettingsConfig(projectID string) (*VersionedSettingsConfig, error)
ExportProjectSettings(projectID, format string, useRelativeIds bool) ([]byte, error)
// Build Types (Jobs)
GetBuildTypes(opts BuildTypesOptions) (*BuildTypeList, error)
GetBuildType(id string) (*BuildType, error)
SetBuildTypePaused(id string, paused bool) error
CreateBuildType(projectID string, req CreateBuildTypeRequest) (*BuildType, error)
BuildTypeExists(id string) bool
CreateBuildStep(buildTypeID string, step BuildStep) error
GetVcsRootEntries(buildTypeID string) (*VcsRootEntries, error)
SetBuildTypeSetting(buildTypeID, setting, value string) error
// Builds (Runs)
GetBuilds(opts BuildsOptions) (*BuildList, error)
GetBuild(ref string) (*Build, error)
ResolveBuildID(ref string) (string, error)
RunBuild(buildTypeID string, opts RunBuildOptions) (*Build, error)
CancelBuild(buildID string, comment string) error
GetBuildLog(buildID string) (string, error)
PinBuild(buildID string, comment string) error
UnpinBuild(buildID string) error
AddBuildTags(buildID string, tags []string) error
GetBuildTags(buildID string) (*TagList, error)
RemoveBuildTag(buildID string, tag string) error
SetBuildComment(buildID string, comment string) error
GetBuildComment(buildID string) (string, error)
DeleteBuildComment(buildID string) error
GetBuildChanges(buildID string) (*ChangeList, error)
GetBuildTests(buildID string, failedOnly bool, limit int) (*TestOccurrences, error)
GetBuildProblems(buildID string) (*ProblemOccurrences, error)
UploadDiffChanges(patch []byte, description string) (string, error)
// Artifacts
GetArtifacts(buildID string) (*Artifacts, error)
DownloadArtifact(buildID, artifactPath string) ([]byte, error)
DownloadArtifactTo(ctx context.Context, buildID, artifactPath string, w io.Writer) (int64, error)
// Build Queue
GetBuildQueue(opts QueueOptions) (*BuildQueue, error)
RemoveFromQueue(id string) error
SetQueuedBuildPosition(buildID string, position int) error
MoveQueuedBuildToTop(buildID string) error
ApproveQueuedBuild(buildID string) error
GetQueuedBuildApprovalInfo(buildID string) (*ApprovalInfo, error)
// Parameters
GetProjectParameters(projectID string) (*ParameterList, error)
GetProjectParameter(projectID, name string) (*Parameter, error)
SetProjectParameter(projectID, name, value string, secure bool) error
DeleteProjectParameter(projectID, name string) error
GetBuildTypeParameters(buildTypeID string) (*ParameterList, error)
GetBuildTypeParameter(buildTypeID, name string) (*Parameter, error)
SetBuildTypeParameter(buildTypeID, name, value string, secure bool) error
DeleteBuildTypeParameter(buildTypeID, name string) error
GetParameterValue(path string) (string, error)
// Agents
GetAgents(opts AgentsOptions) (*AgentList, error)
GetAgent(id int) (*Agent, error)
GetAgentByName(name string) (*Agent, error)
AuthorizeAgent(id int, authorized bool) error
EnableAgent(id int, enabled bool) error
RebootAgent(ctx context.Context, id int, afterBuild bool) error
GetAgentCompatibleBuildTypes(id int) (*BuildTypeList, error)
GetAgentIncompatibleBuildTypes(id int) (*CompatibilityList, error)
// Agent Pools
GetAgentPools(fields []string) (*PoolList, error)
GetAgentPool(id int) (*Pool, error)
AddProjectToPool(poolID int, projectID string) error
RemoveProjectFromPool(poolID int, projectID string) error
SetAgentPool(agentID int, poolID int) error
// Raw API access
RawRequest(method, path string, body io.Reader, headers map[string]string) (*RawResponse, error)
}
ClientInterface defines the TeamCity API client interface. Cmd package uses this interface for dependency injection in tests.
type ClientOption ¶
type ClientOption func(*Client)
ClientOption allows configuring the client
func WithAPIVersion ¶
func WithAPIVersion(version string) ClientOption
WithAPIVersion pins the client to a specific API version
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout sets a custom HTTP timeout
type Compatibility ¶ added in v0.2.0
type Compatibility struct {
Compatible bool `json:"compatible"`
BuildType *BuildType `json:"buildType,omitempty"`
Agent *Agent `json:"agent,omitempty"`
Reasons *IncompatibleReasons `json:"incompatibleReasons,omitempty"`
}
Compatibility represents build type compatibility info
type CompatibilityList ¶ added in v0.2.0
type CompatibilityList struct {
Count int `json:"count"`
Compatibility []Compatibility `json:"compatibility"`
}
CompatibilityList represents a list of compatibility entries
type Content ¶
type Content struct {
Href string `json:"href"`
}
Content represents artifact content reference
type CreateBuildTypeRequest ¶
CreateBuildTypeRequest represents a request to create a build configuration
type CreateProjectRequest ¶
type CreateProjectRequest struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
ParentProjectID string `json:"parentProject,omitempty"`
}
CreateProjectRequest represents a request to create a project
type CreateUserRequest ¶
type CreateUserRequest struct {
Username string `json:"username"`
Password string `json:"password"`
Name string `json:"name,omitempty"`
Email string `json:"email,omitempty"`
Roles RoleList `json:"roles,omitempty"`
}
CreateUserRequest represents a request to create a user
type FileChange ¶
type Files ¶
type Files struct {
File []FileChange `json:"file"`
}
type IncompatibleReasons ¶ added in v0.2.0
type IncompatibleReasons struct {
Reasons []string `json:"reason,omitempty"`
}
IncompatibleReasons contains reasons why an agent can't run a build type
type LastChanges ¶ added in v0.2.0
type LastChanges struct {
Change []PersonalChange `json:"change"`
}
LastChanges represents the changes to include in a build
type Locator ¶
type Locator struct {
// contains filtered or unexported fields
}
func NewLocator ¶
func NewLocator() *Locator
func (*Locator) AddIntDefault ¶
type Parameter ¶
type Parameter struct {
Name string `json:"name"`
Value string `json:"value"`
Type *ParameterType `json:"type,omitempty"`
}
Parameter represents a TeamCity parameter
type ParameterList ¶
ParameterList represents a list of parameters
type ParameterType ¶
type ParameterType struct {
RawValue string `json:"rawValue,omitempty"`
}
ParameterType represents parameter type info
type PersonalChange ¶ added in v0.2.0
PersonalChange represents a personal change (uploaded diff) reference
type Pool ¶
type Pool struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Href string `json:"href,omitempty"`
MaxAgents int `json:"maxAgents,omitempty"`
Projects *ProjectList `json:"projects,omitempty"`
Agents *AgentList `json:"agents,omitempty"`
}
Pool represents an agent pool
type ProblemOccurrence ¶ added in v0.4.0
type ProblemOccurrences ¶ added in v0.4.0
type ProblemOccurrences struct {
Count int `json:"count"`
ProblemOccurrence []ProblemOccurrence `json:"problemOccurrence"`
}
type Project ¶
type Project struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
ParentProjectID string `json:"parentProjectId,omitempty"`
Href string `json:"href,omitempty"`
WebURL string `json:"webUrl,omitempty"`
}
Project represents a TeamCity project
type ProjectList ¶
ProjectList represents a list of projects
type ProjectsOptions ¶
ProjectsOptions represents options for listing projects
type PropertyList ¶
type PropertyList struct {
Property []Property `json:"property"`
}
PropertyList represents a list of properties
type QueueOptions ¶
QueueOptions represents options for listing queued builds
type QueuedBuild ¶
type QueuedBuild struct {
ID int `json:"id"`
BuildTypeID string `json:"buildTypeId,omitempty"`
State string `json:"state,omitempty"`
BranchName string `json:"branchName,omitempty"`
Href string `json:"href,omitempty"`
WebURL string `json:"webUrl,omitempty"`
BuildType *BuildType `json:"buildType,omitempty"`
Triggered *Triggered `json:"triggered,omitempty"`
QueuedDate string `json:"queuedDate,omitempty"`
}
QueuedBuild represents a build in the queue
type RawResponse ¶
RawResponse represents the response from a raw API request
type RetryConfig ¶
RetryConfig defines retry behavior for API operations.
type Revision ¶ added in v0.2.0
type Revision struct {
Version string `json:"version"`
VcsBranchName string `json:"vcsBranchName,omitempty"`
VcsRootInstance *VcsRootInstanceRef `json:"vcs-root-instance,omitempty"`
}
type Role ¶
type Role struct {
RoleID string `json:"roleId"`
Scope string `json:"scope"` // "g" for global, "p:ProjectID" for project
}
Role represents a TeamCity role assignment
type RoleList ¶
type RoleList struct {
Role []Role `json:"role"`
}
RoleList represents a list of role assignments
type RunBuildOptions ¶
type RunBuildOptions struct {
Branch string
Params map[string]string // Configuration parameters
SystemProps map[string]string // System properties (system.*)
EnvVars map[string]string // Environment variables (env.*)
Comment string
Personal bool
CleanSources bool
RebuildDependencies bool
QueueAtTop bool
RebuildFailedDependencies bool
AgentID int
Tags []string
PersonalChangeID string
Revision string
}
RunBuildOptions represents options for running a build
type Server ¶
type Server struct {
Version string `json:"version"`
VersionMajor int `json:"versionMajor"`
VersionMinor int `json:"versionMinor"`
BuildNumber string `json:"buildNumber"`
WebURL string `json:"webUrl"`
}
Server represents TeamCity server info
type TerminalClient ¶ added in v0.3.0
type TerminalClient struct {
// contains filtered or unexported fields
}
func NewTerminalClient ¶ added in v0.3.0
func NewTerminalClient(baseURL, username, token string) *TerminalClient
func (*TerminalClient) Connect ¶ added in v0.3.0
func (c *TerminalClient) Connect(session *TerminalSession, cols, rows int) (*TerminalConn, error)
func (*TerminalClient) OpenSession ¶ added in v0.3.0
func (c *TerminalClient) OpenSession(agentID int) (*TerminalSession, error)
type TerminalConn ¶ added in v0.3.0
type TerminalConn struct {
// contains filtered or unexported fields
}
func (*TerminalConn) Close ¶ added in v0.3.0
func (tc *TerminalConn) Close()
func (*TerminalConn) Exec ¶ added in v0.3.0
func (tc *TerminalConn) Exec(ctx context.Context, command string) error
func (*TerminalConn) RunInteractive ¶ added in v0.3.0
func (tc *TerminalConn) RunInteractive(ctx context.Context) error
type TerminalSession ¶ added in v0.3.0
TerminalSession holds the session token and node ID from TeamCity's agent terminal plugin
type TestOccurrence ¶
type TestOccurrences ¶
type TestOccurrences struct {
Count int `json:"count"`
Passed int `json:"passed,omitempty"`
Failed int `json:"failed,omitempty"`
Ignored int `json:"ignored,omitempty"`
TestOccurrence []TestOccurrence `json:"testOccurrence"`
}
type TriggerBuildRequest ¶
type TriggerBuildRequest struct {
BuildType BuildTypeRef `json:"buildType"`
BranchName string `json:"branchName,omitempty"`
Properties *PropertyList `json:"properties,omitempty"`
Comment *BuildComment `json:"comment,omitempty"`
Personal bool `json:"personal,omitempty"`
TriggeringOptions *TriggeringOptions `json:"triggeringOptions,omitempty"`
Agent *AgentRef `json:"agent,omitempty"`
Tags *TagList `json:"tags,omitempty"`
LastChanges *LastChanges `json:"lastChanges,omitempty"`
Revisions *Revisions `json:"revisions,omitempty"`
}
TriggerBuildRequest represents a request to trigger a build
type Triggered ¶
type Triggered struct {
Type string `json:"type,omitempty"`
Date string `json:"date,omitempty"`
User *User `json:"user,omitempty"`
}
Triggered represents who/what triggered a build
type TriggeringOptions ¶
type TriggeringOptions struct {
CleanSources bool `json:"cleanSources,omitempty"`
RebuildAllDependencies bool `json:"rebuildAllDependencies,omitempty"`
QueueAtTop bool `json:"queueAtTop,omitempty"`
RebuildFailedOrIncomplete bool `json:"rebuildFailedOrIncompleteDependencies,omitempty"`
}
TriggeringOptions represents options for triggering a build
type User ¶
type User struct {
ID int `json:"id,omitempty"`
Username string `json:"username,omitempty"`
Name string `json:"name,omitempty"`
Email string `json:"email,omitempty"`
Href string `json:"href,omitempty"`
}
User represents a TeamCity user
type VcsRootEntries ¶ added in v0.5.0
type VcsRootEntries struct {
Count int `json:"count"`
VcsRootEntry []VcsRootEntry `json:"vcs-root-entry"`
}
type VcsRootEntry ¶ added in v0.5.0
type VcsRootEntry struct {
ID string `json:"id,omitempty"`
VcsRoot *VcsRootRef `json:"vcs-root,omitempty"`
}
type VcsRootInstanceRef ¶ added in v0.5.0
type VcsRootInstanceRef struct {
VcsRootID string `json:"vcs-root-id"`
}
type VcsRootRef ¶ added in v0.5.0
type VersionedSettingsConfig ¶ added in v0.3.0
type VersionedSettingsConfig struct {
SynchronizationMode string `json:"synchronizationMode,omitempty"` // enabled, disabled
Format string `json:"format,omitempty"` // kotlin, xml
BuildSettingsMode string `json:"buildSettingsMode,omitempty"` // useFromVCS, useCurrentByDefault
VcsRootID string `json:"vcsRootId,omitempty"`
SettingsPath string `json:"settingsPath,omitempty"`
AllowUIEditing bool `json:"allowUIEditing,omitempty"`
ShowSettingsChanges bool `json:"showSettingsChanges,omitempty"`
}
VersionedSettingsConfig represents the configuration of versioned settings
type VersionedSettingsStatus ¶ added in v0.3.0
type VersionedSettingsStatus struct {
Type string `json:"type,omitempty"` // info, warning, error
Message string `json:"message,omitempty"` // Human-readable status message
Timestamp string `json:"timestamp,omitempty"` // When the status was recorded
DslOutdated bool `json:"dslOutdated,omitempty"` // DSL scripts need regeneration
}
VersionedSettingsStatus represents the sync status of versioned settings