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

create scm servers always return match server

Signed-off-by: Nrunzexia <runzexia@yunify.com>
上级 f22e8ea9
...@@ -148,6 +148,31 @@ func GetSCMServers(scmId string, req *http.Request) ([]byte, error) { ...@@ -148,6 +148,31 @@ func GetSCMServers(scmId string, req *http.Request) ([]byte, error) {
} }
func CreateSCMServers(scmId string, req *http.Request) ([]byte, error) { func CreateSCMServers(scmId string, req *http.Request) ([]byte, error) {
requestBody, err := ioutil.ReadAll(req.Body)
if err != nil {
log.Error(err)
return nil, err
}
createReq := &CreateScmServerReq{}
err = json.Unmarshal(requestBody, createReq)
if err != nil {
log.Error(err)
return nil, err
}
req.Body = nil
byteServers, err := GetSCMServers(scmId, req)
if err != nil {
log.Error(err)
return nil, err
}
var servers []*SCMServer
_ = json.Unmarshal(byteServers, &servers)
for _, server := range servers {
if server.ApiURL == createReq.ApiURL {
return json.Marshal(server)
}
}
req.Body = ioutil.NopCloser(bytes.NewReader(requestBody))
baseUrl := fmt.Sprintf(jenkins.Server+CreateSCMServersUrl, scmId) baseUrl := fmt.Sprintf(jenkins.Server+CreateSCMServersUrl, scmId)
log.Info("Jenkins-url: " + baseUrl) log.Info("Jenkins-url: " + baseUrl)
req.Method = http.MethodPost req.Method = http.MethodPost
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册