Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cherry-pick #7112 fix: sonarqube test connection can not effective #7113

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions backend/plugins/sonarqube/api/connection_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package api

import (
"context"
"fmt"
"net/http"

"github.com/apache/incubator-devlake/core/errors"
Expand Down Expand Up @@ -95,6 +96,10 @@ func TestConnection(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput,
if testConnectionErr != nil {
return nil, plugin.WrapTestConnectionErrResp(basicRes, testConnectionErr)
}
if testConnectionResult.Status != http.StatusOK {
errMsg := fmt.Sprintf("Test connection fail, unexpected status code: %d", testConnectionResult.Status)
return nil, plugin.WrapTestConnectionErrResp(basicRes, errors.Default.New(errMsg))
}
return &plugin.ApiResourceOutput{Body: testConnectionResult, Status: http.StatusOK}, nil
}

Expand All @@ -116,6 +121,10 @@ func TestExistingConnection(input *plugin.ApiResourceInput) (*plugin.ApiResource
if testConnectionErr != nil {
return nil, plugin.WrapTestConnectionErrResp(basicRes, testConnectionErr)
}
if testConnectionResult.Status != http.StatusOK {
errMsg := fmt.Sprintf("Test connection fail, unexpected status code: %d", testConnectionResult.Status)
return nil, plugin.WrapTestConnectionErrResp(basicRes, errors.Default.New(errMsg))
}
return &plugin.ApiResourceOutput{Body: testConnectionResult, Status: http.StatusOK}, nil
}

Expand Down
Loading