From 636bd3f1c656095e57ad19e6152d5494c01d28fc Mon Sep 17 00:00:00 2001 From: Michael Kobaly Date: Wed, 9 Nov 2016 10:07:15 -0500 Subject: [PATCH] Added call to get BuildTypes --- build.go | 23 +++++++++++++---------- client.go | 17 +++++++++++++++++ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/build.go b/build.go index c8574c9..2d08ccf 100644 --- a/build.go +++ b/build.go @@ -2,20 +2,23 @@ package teamcity import "fmt" +// BuildType represents a Teamcity Build Type +type BuildType struct { + ID string + Name string + Description string + ProjectName string + ProjectID string + HREF string + WebURL string +} + // Build represents a TeamCity build, along with its metadata. type Build struct { ID int64 BuildTypeID string - BuildType struct { - ID string - Name string - Description string - ProjectName string - ProjectID string - HREF string - WebURL string - } - Triggered struct { + BuildType BuildType + Triggered struct { Type string Date JSONTime User struct { diff --git a/client.go b/client.go index 106613d..b9817d8 100644 --- a/client.go +++ b/client.go @@ -60,6 +60,23 @@ func (c *Client) QueueBuild(buildTypeID string, branchName string, properties ma return build, nil } +func (c *Client) GetBuildTypes() ([]*BuildType, error) { + path := "/httpAuth/app/rest/buildTypes" + + respStruct := struct { + Count int + BuildType []*BuildType + }{} + retries := 8 + err := withRetry(retries, func() error { + return c.doRequest("GET", path, nil, &respStruct) + }) + if err != nil { + return nil, err + } + return respStruct.BuildType, nil +} + func (c *Client) SearchBuild(locator string) ([]*Build, error) { path := fmt.Sprintf("/httpAuth/app/rest/builds/?locator=%s&fields=count,build(*,tags(tag),triggered(*),properties(property),problemOccurrences(*,problemOccurrence(*)),testOccurrences(*,testOccurrence(*)),changes(*,change(*)))", locator)