Skip to content

Commit

Permalink
Merge pull request bndr#150 from kforsthoevel/add-console-output-from…
Browse files Browse the repository at this point in the history
…-index

Output progressiveText in order to tail logs
  • Loading branch information
bndr authored Oct 9, 2018
2 parents 77a0db8 + e84cd78 commit e1cded9
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ type BuildResponse struct {
} `json:"runs"`
}

type consoleResponse struct {
Content string
Offset int64
HasMoreText bool
}

// Builds
func (b *Build) Info() *BuildResponse {
return b.Raw
Expand Down Expand Up @@ -237,6 +243,29 @@ func (b *Build) GetConsoleOutput() string {
return content
}

func (b *Build) GetConsoleOutputFromIndex(startID int64) (consoleResponse, error) {
strstart := strconv.FormatInt(startID, 10)
url := b.Base + "/logText/progressiveText"

var console consoleResponse

querymap := make(map[string]string)
querymap["start"] = strstart
rsp, err := b.Jenkins.Requester.Get(url, &console.Content, querymap)
if err != nil {
return console, err
}

textSize := rsp.Header.Get("X-Text-Size")
console.HasMoreText = len(rsp.Header.Get("X-More-Data")) != 0
console.Offset, err = strconv.ParseInt(textSize, 10, 64)
if err != nil {
return console, err
}

return console, err
}

func (b *Build) GetCauses() ([]map[string]interface{}, error) {
_, err := b.Poll()
if err != nil {
Expand Down

0 comments on commit e1cded9

Please sign in to comment.