...
|
...
|
@@ -3,6 +3,8 @@ package com.ui.ctrl.app; |
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.ui.app.common.ErrorCode;
|
|
|
import com.ui.app.req.*;
|
|
|
import com.ui.app.resp.NodeBuildResp;
|
|
|
import com.ui.app.resp.NodeBuildState;
|
|
|
import com.ui.contants.HttpUriContants;
|
|
|
import com.ui.http.HttpRestClient;
|
|
|
import com.ui.model.BaseResponse;
|
...
|
...
|
@@ -61,14 +63,6 @@ public class AppProjectBuildCtrl { |
|
|
*/
|
|
|
@RequestMapping(value = "app_getrollbacklist", method = RequestMethod.POST)
|
|
|
public BaseResponse rollbackList(@RequestBody RollbackList rollbackListReq) {
|
|
|
//rollbackListReq.setEnvironment("test");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BaseResponse baseResponse = new BaseResponse();
|
|
|
if (StringUtils.isBlank(rollbackListReq.getProject()) || StringUtils.isBlank(rollbackListReq.getEnvironment())) {
|
...
|
...
|
@@ -97,14 +91,6 @@ public class AppProjectBuildCtrl { |
|
|
*/
|
|
|
@RequestMapping(value = "app_build", method = RequestMethod.POST)
|
|
|
public BaseResponse build(@RequestBody ProjectBuild projectBuild) {
|
|
|
// projectBuild.setEnvironment("test");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BaseResponse baseResponse = new BaseResponse();
|
|
|
String project = projectBuild.getProject();
|
...
|
...
|
@@ -207,4 +193,116 @@ public class AppProjectBuildCtrl { |
|
|
return baseResponse;
|
|
|
}
|
|
|
|
|
|
private static final String PHP_URL = "http://node-ci.yohops.com/api/";
|
|
|
|
|
|
/**
|
|
|
* 获取项目列表
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "app_getnodeprojectlist", method = RequestMethod.POST)
|
|
|
public BaseResponse getnodeprojectlist(@RequestBody NodeProjectList nodeProjectList) {
|
|
|
BaseResponse baseResponse = new BaseResponse();
|
|
|
if (StringUtils.isBlank(nodeProjectList.getEnvironment())) {
|
|
|
baseResponse.setCode(ErrorCode.PARAM_ERROR);
|
|
|
baseResponse.setMessage(ErrorCode.PARAM_ERROR_MESSAGE);
|
|
|
return baseResponse;
|
|
|
}
|
|
|
|
|
|
String environment = nodeProjectList.getEnvironment();
|
|
|
if ("qcloud_gray".equals(environment)) {
|
|
|
environment = "qcloud";
|
|
|
}
|
|
|
String result = httpClient.get(PHP_URL + "projects?cloud=" + environment, String.class, null);
|
|
|
if (result == null) {
|
|
|
baseResponse.setCode(ErrorCode.SYSTEM_ERROR);
|
|
|
baseResponse.setMessage("fail to get node/php project list");
|
|
|
return baseResponse;
|
|
|
}
|
|
|
baseResponse.setData(JSONArray.parse(result));
|
|
|
return baseResponse;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取回滚列表
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "app_getnoderollbacklist", method = RequestMethod.POST)
|
|
|
public BaseResponse getnoderollbacklist(@RequestBody NodeRollbackList nodeRollbackList) {
|
|
|
BaseResponse baseResponse = new BaseResponse();
|
|
|
if (StringUtils.isBlank(nodeRollbackList.getEnvironment()) || StringUtils.isBlank(nodeRollbackList.getId())) {
|
|
|
baseResponse.setCode(ErrorCode.PARAM_ERROR);
|
|
|
baseResponse.setMessage(ErrorCode.PARAM_ERROR_MESSAGE);
|
|
|
return baseResponse;
|
|
|
}
|
|
|
|
|
|
String env = "production";
|
|
|
String environment = nodeRollbackList.getEnvironment();
|
|
|
if ("qcloud_gray".equals(environment)) {
|
|
|
env = "preview";
|
|
|
}
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("id", nodeRollbackList.getId());
|
|
|
map.put("env", env);
|
|
|
|
|
|
String result = httpClient.get(PHP_URL + "builds", String.class, map);
|
|
|
if (result == null) {
|
|
|
baseResponse.setCode(ErrorCode.SYSTEM_ERROR);
|
|
|
baseResponse.setMessage("fail to get biuld list");
|
|
|
return baseResponse;
|
|
|
}
|
|
|
|
|
|
baseResponse.setData(JSONArray.parse(result));
|
|
|
return baseResponse;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 发布
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "app_nodebuild", method = RequestMethod.POST)
|
|
|
public BaseResponse nodebuild(@RequestBody NodeBuild nodeBuild) {
|
|
|
BaseResponse baseResponse = new BaseResponse();
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
|
if ("Deploy".equals(nodeBuild.getOperate())) {
|
|
|
String env = "production";
|
|
|
String environment = nodeBuild.getEnvironment();
|
|
|
if ("qcloud_gray".equals(environment)) {
|
|
|
env = "preview";
|
|
|
}
|
|
|
map.put("id", nodeBuild.getId());
|
|
|
map.put("env", env);
|
|
|
map.put("branch", nodeBuild.getBranch());
|
|
|
NodeBuildResp result = httpClient.get(PHP_URL + "publish", NodeBuildResp.class, map);
|
|
|
baseResponse.setData(result.getBid());
|
|
|
} else {
|
|
|
map.put("id", nodeBuild.getRollbackfile());
|
|
|
NodeBuildResp result = httpClient.get(PHP_URL + "rollback", NodeBuildResp.class, map);
|
|
|
baseResponse.setData(result.getBid());
|
|
|
|
|
|
}
|
|
|
return baseResponse;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 状态查询
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "app_getnoderesult", method = RequestMethod.POST)
|
|
|
public BaseResponse getnoderesult(@RequestBody NodeMsg nodeMsg) {
|
|
|
BaseResponse baseResponse = new BaseResponse();
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("bid", nodeMsg.getBuildNo());
|
|
|
NodeBuildState result = httpClient.get(PHP_URL + "state", NodeBuildState.class, map);
|
|
|
baseResponse.setData(result);
|
|
|
return baseResponse;
|
|
|
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|