-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix build discarder strategies and tests
- Loading branch information
Showing
25 changed files
with
305 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package client | ||
|
||
import "encoding/xml" | ||
|
||
type JobBuildDiscarderProperty struct { | ||
XMLName xml.Name `xml:"jenkins.model.BuildDiscarderProperty"` | ||
Id string `xml:"id,attr"` | ||
|
||
Strategy JobBuildDiscarderPropertyStrategyXml `xml:"strategy"` | ||
} | ||
|
||
func NewJobBuildDiscarderProperty() *JobBuildDiscarderProperty { | ||
return &JobBuildDiscarderProperty{} | ||
} | ||
|
||
func (property *JobBuildDiscarderProperty) GetId() string { | ||
return property.Id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package client | ||
|
||
import ( | ||
"log" | ||
"encoding/xml" | ||
) | ||
|
||
type JobBuildDiscarderPropertyStrategyXml struct { | ||
Item JobBuildDiscarderPropertyStrategy `xml:",any"` | ||
} | ||
|
||
type JobBuildDiscarderPropertyStrategy interface{} | ||
|
||
func (strategy *JobBuildDiscarderPropertyStrategyXml) MarshalXML(e *xml.Encoder, start xml.StartElement) error { | ||
return e.EncodeElement(strategy.Item, start) | ||
} | ||
|
||
func (strategy *JobBuildDiscarderPropertyStrategyXml) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { | ||
for _, attr := range start.Attr { | ||
switch attr.Name.Local { | ||
case "class": | ||
switch attr.Value { | ||
default: | ||
case "hudson.tasks.LogRotator": | ||
newStrategy := NewJobBuildDiscarderPropertyStrategyLogRotator() | ||
strategy.Item = newStrategy | ||
return d.DecodeElement(newStrategy, &start) | ||
} | ||
} | ||
} | ||
|
||
log.Println("[WARN] Unable to unmarshal build discarder property strategy xml. Unknown or missing class") | ||
var err error | ||
// must read all of doc or it complains | ||
for _, err := d.Token(); err == nil; _, err = d.Token() { | ||
} | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.