...
|
...
|
@@ -161,6 +161,7 @@ public class DockerProjectCtrl { |
|
|
String userMail=dockerJenkinsReq.getUserMail();
|
|
|
String branch=dockerJenkinsReq.getBranch();
|
|
|
String nodeEnv=dockerJenkinsReq.getNodeEnv();
|
|
|
String work_release_id=dockerJenkinsReq.getReleaseWorkId();
|
|
|
StringBuilder buildIdSb=new StringBuilder();
|
|
|
StringBuilder failSb=new StringBuilder();
|
|
|
for(String id:ids.split(",")){
|
...
|
...
|
@@ -177,6 +178,7 @@ public class DockerProjectCtrl { |
|
|
dockerJenkinsReqSingle.setProjectPort(model.getPort());
|
|
|
|
|
|
//页面传过来的参数
|
|
|
dockerJenkinsReqSingle.setReleaseWorkId(work_release_id);
|
|
|
dockerJenkinsReqSingle.setUserMail(userMail);
|
|
|
dockerJenkinsReqSingle.setBranch(branch);
|
|
|
dockerJenkinsReqSingle.setNodeEnv(nodeEnv);
|
...
|
...
|
@@ -457,6 +459,69 @@ public class DockerProjectCtrl { |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取发布docker的回滚版本
|
|
|
*/
|
|
|
@RequestMapping(value = "/getRollbackList")
|
|
|
@ResponseBody
|
|
|
public String getRollbackList(String projectId, String environment) {
|
|
|
DockerProjectModel model=dockerProjectMapper.selectById(Integer.parseInt(projectId));
|
|
|
if(model!=null){
|
|
|
String imageStore=model.getDockerOnlineImageStore();
|
|
|
if(environment!=null&&environment.toUpperCase().indexOf("GRAY")>0){
|
|
|
imageStore=model.getDockerGrayImageStore();
|
|
|
}
|
|
|
return JSON.toJSONString(dockerServerDeployService.queryImageList(imageStore,model.getDockerProjectName()));
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* docker的回滚
|
|
|
*/
|
|
|
@RequestMapping(value = "/rollback")
|
|
|
@ResponseBody
|
|
|
public BaseResponse rollback(String projectId, String environment, String rollbackImageStore) {
|
|
|
BaseResponse rtn=new BaseResponse();
|
|
|
DockerProjectModel model=dockerProjectMapper.selectById(Integer.parseInt(projectId));
|
|
|
if(model==null){
|
|
|
rtn.setCode(201);
|
|
|
rtn.setMessage("找不到docker project配置信息!");
|
|
|
return rtn;
|
|
|
}
|
|
|
|
|
|
String clusterId=model.getDockerOnlineClusterId();
|
|
|
String namespace=model.getDockerOnlineNameSpace();
|
|
|
if(environment!=null&&environment.toUpperCase().indexOf("GRAY")>0){
|
|
|
clusterId=model.getDockerGrayClusterId();
|
|
|
namespace=model.getDockerGrayNameSpace();
|
|
|
}
|
|
|
String serviceName=model.getDockerProjectName();
|
|
|
if(!dockerServerDeployService.checkAppIsExist(clusterId,namespace,serviceName)){
|
|
|
rtn.setCode(201);
|
|
|
rtn.setMessage("Docker服务不存在,请联系运维人员");
|
|
|
return rtn;
|
|
|
}
|
|
|
|
|
|
Map<String,Object> statusMap=dockerServerDeployService.checkAppStatusIsNormal(clusterId,namespace,serviceName);
|
|
|
boolean normalStatusFlag=(boolean)statusMap.get("result");
|
|
|
if(!normalStatusFlag){
|
|
|
rtn.setCode(201);
|
|
|
rtn.setMessage("Docker服务非Normal状态,发布中止!");
|
|
|
return rtn;
|
|
|
}
|
|
|
JSONArray containerJa=(JSONArray)statusMap.get("containerJa");
|
|
|
|
|
|
//更改路径,更改之后自动重新部署
|
|
|
boolean currentImageLatestFlag=dockerServerDeployService.modifyImageStore(clusterId, namespace, serviceName, containerJa,rollbackImageStore);
|
|
|
if(!currentImageLatestFlag){
|
|
|
rtn.setCode(201);
|
|
|
rtn.setMessage("Docker服务修改镜像服务发生异常");
|
|
|
return rtn;
|
|
|
}
|
|
|
return rtn;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 发布docker服务
|
|
|
*/
|
|
|
@RequestMapping("/queryDockerServerStatus")
|
...
|
...
|
|