fix sonarStatus api NEP, return [] if could not get last run

Signed-off-by: runzexia <runzexia@yunify.com>
This commit is contained in:
runzexia
2019-05-14 16:29:54 +08:00
parent 86c7cf6185
commit a6f46bc84a
2 changed files with 7 additions and 2 deletions

View File

@@ -273,9 +273,12 @@ func GetMultiBranchPipelineSonar(projectId, pipelineId, branchId string) ([]*Son
return nil, restful.NewError(utils.GetJenkinsStatusCode(err), err.Error())
}
build, err := job.GetLastBuild()
if err != nil {
if err != nil && utils.GetJenkinsStatusCode(err) != http.StatusNotFound {
glog.Errorf("%+v", err)
return nil, restful.NewError(utils.GetJenkinsStatusCode(err), err.Error())
} else if err != nil {
glog.Error("%+v", err)
return nil, nil
}
sonarStatus, err := getBuildSonarResults(build)
@@ -288,6 +291,9 @@ func GetMultiBranchPipelineSonar(projectId, pipelineId, branchId string) ([]*Son
if err != nil && utils.GetJenkinsStatusCode(err) != http.StatusNotFound {
glog.Errorf("%+v", err)
return nil, restful.NewError(utils.GetJenkinsStatusCode(err), err.Error())
} else if err != nil {
glog.Error("%+v", err)
return nil, nil
}
sonarStatus, err = getBuildSonarResults(build)
if err != nil {

View File

@@ -369,7 +369,6 @@ func createOrUpdateRouterWorkload(namespace string, publishService bool, service
}
}
if deployment.Spec.Template.Annotations == nil {
deployment.Spec.Template.Annotations = make(map[string]string, 0)
}