未验证 提交 ca99e0a0 编写于 作者: R runzexia 提交者: GitHub

Merge pull request #422 from runzexia/fix-sonar-status-NPE

fix sonarStatus api NEP, return `[]` if could not get last run
......@@ -235,9 +235,12 @@ func GetPipelineSonar(projectId, pipelineId string) ([]*SonarStatus, error) {
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.Errorf("%+v", err)
return nil, nil
}
sonarStatus, err := getBuildSonarResults(build)
......@@ -250,6 +253,9 @@ func GetPipelineSonar(projectId, pipelineId string) ([]*SonarStatus, error) {
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.Errorf("%+v", err)
return nil, nil
}
sonarStatus, err = getBuildSonarResults(build)
if err != nil {
......@@ -273,9 +279,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.Errorf("%+v", err)
return nil, nil
}
sonarStatus, err := getBuildSonarResults(build)
......@@ -288,6 +297,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.Errorf("%+v", err)
return nil, nil
}
sonarStatus, err = getBuildSonarResults(build)
if err != nil {
......
......@@ -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)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册