Skip to content

Commit 6a8dfdb

Browse files
committedAug 23, 2018
add BuildDisplayName to history item
1 parent 321ec70 commit 6a8dfdb

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed
 

‎build_history.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ func parseBuildHistory(d io.Reader) []*History {
1414
depth := 0
1515
buildRowCellDepth := -1
1616
builds := make([]*History, 0)
17+
isInsideDisplayName := false
1718
var curBuild *History
1819
for {
1920
tt := z.Next()
@@ -52,11 +53,12 @@ func parseBuildHistory(d io.Reader) []*History {
5253
}
5354
// <a update-parent-class=".build-row" href="/job/appscode/job/43/job/build-binary/227/" class="tip model-link inside build-link display-name">#227</a>
5455
if string(tn) == "a" {
55-
if hasCSSClass(a, "build-link") && buildRowCellDepth > -1 {
56+
if hasCSSClass(a, "display-name") && buildRowCellDepth > -1 {
5657
if href, found := a["href"]; found {
5758
parts := strings.Split(href, "/")
5859
if num, err := strconv.Atoi(parts[len(parts)-2]); err == nil {
5960
curBuild.BuildNumber = num
61+
isInsideDisplayName = true
6062
}
6163
}
6264
}
@@ -72,6 +74,11 @@ func parseBuildHistory(d io.Reader) []*History {
7274
}
7375
}
7476
}
77+
case html.TextToken:
78+
if isInsideDisplayName {
79+
curBuild.BuildDisplayName = z.Token().Data
80+
isInsideDisplayName = false
81+
}
7582
case html.EndTagToken:
7683
tn, _ := z.TagName()
7784
if string(tn) == "td" && depth == buildRowCellDepth {

‎job.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ func (j *Job) parentBase() string {
100100
}
101101

102102
type History struct {
103-
BuildNumber int
104-
BuildStatus string
105-
BuildTimestamp int64
103+
BuildDisplayName string
104+
BuildNumber int
105+
BuildStatus string
106+
BuildTimestamp int64
106107
}
107108

108109
func (j *Job) GetName() string {

0 commit comments

Comments
 (0)
Please sign in to comment.