未验证 提交 d5fdfd51 编写于 作者: K KubeSphere CI Bot 提交者: GitHub

Merge pull request #3550 from LinuxSuRen/fix-url-redundant-check

Fix the BitBucket endpoint URL redundant checking
......@@ -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
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册