Skip to content

Commit

Permalink
fix error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bootjp committed Mar 31, 2021
1 parent ee187d2 commit 4fc15fe
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,23 +166,17 @@ func DetectFailJobs(jobs []*gojenkins.Job) []*FailJob {

lastBuild, err := job.GetLastBuild()
if err != nil {
ids, _ := job.GetAllBuildIds()
if len(ids) == 0 {
switch err.Error() {
case "404":
continue
default:
ej := &FailJob{
JenkinsJob: job,
Err: err,
Reason: ReasonOverHoursFailedJob,
}
errorJobs = append(errorJobs, ej)
}

logger.Println("got err GetLastBuild by " + job.GetName() + " call by DetectFailJobs")
fmt.Printf("%v", lastBuild)
logger.Println(err)
logger.Println(errors.WithStack(err))

ej := &FailJob{
JenkinsJob: job,
Err: err,
Reason: ReasonJenkinsError,
}
errorJobs = append(errorJobs, ej)
continue
}

switch lastBuild.GetResult() {
Expand Down

0 comments on commit 4fc15fe

Please sign in to comment.