Fix the BitBucket endpoint URL redundant checking
Signed-off-by: rick <1450685+LinuxSuRen@users.noreply.github.com>
This commit is contained in:
@@ -542,7 +542,7 @@ func AddPipelineToWebService(webservice *restful.WebService, devopsClient devops
|
||||
webservice.Route(webservice.POST("/scms/{scm}/servers").
|
||||
To(projectPipelineHandler.CreateSCMServers).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{constants.DevOpsScmTag}).
|
||||
Doc("Create scm server in the jenkins.").
|
||||
Doc("Create scm server if it does not exist in the Jenkins.").
|
||||
Param(webservice.PathParameter("scm", "The ID of the source configuration management (SCM).")).
|
||||
Reads(devops.CreateScmServerReq{}).
|
||||
Returns(http.StatusOK, RespOK, devops.SCMServer{}).
|
||||
|
||||
@@ -43,6 +43,7 @@ import (
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/devops"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -826,6 +827,7 @@ func (d devopsOperator) GetOrgRepo(scmId, organizationId string, req *http.Reque
|
||||
return res, err
|
||||
}
|
||||
|
||||
// CreateSCMServers creates a Bitbucket server config item in Jenkins configuration if there's no same API address exist
|
||||
func (d devopsOperator) CreateSCMServers(scmId string, req *http.Request) (*devops.SCMServer, error) {
|
||||
|
||||
requestBody, err := ioutil.ReadAll(req.Body)
|
||||
@@ -846,8 +848,9 @@ func (d devopsOperator) CreateSCMServers(scmId string, req *http.Request) (*devo
|
||||
return nil, err
|
||||
}
|
||||
|
||||
createReq.ApiURL = strings.TrimSuffix(createReq.ApiURL, "/")
|
||||
for _, server := range servers {
|
||||
if server.ApiURL == createReq.ApiURL {
|
||||
if strings.TrimSuffix(server.ApiURL, "/") == createReq.ApiURL {
|
||||
return &server, nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user