...
|
...
|
@@ -27,6 +27,7 @@ import java.util.ArrayList; |
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
|
|
|
|
|
|
@RestController
|
...
|
...
|
@@ -81,6 +82,8 @@ public class DockerBuildCtrl { |
|
|
model.addAttribute("releaseWorkJob_projectDeployType", map.get("projectDeployType")==null?"":(String)map.get("projectDeployType"));
|
|
|
model.addAttribute("releaseWorkJob_branch", map.get("branch")==null?"":(String)map.get("branch"));
|
|
|
model.addAttribute("releaseWorkJob_imageFile", map.get("imageFile")==null?"":(String)map.get("imageFile"));
|
|
|
model.addAttribute("releaseWorkJob_uploadCDN", map.get("uploadCDN")==null?"":String.valueOf(map.get("uploadCDN")));
|
|
|
model.addAttribute("releaseWorkJob_cdnBranch", map.get("cdnBranch")==null?"":String.valueOf(map.get("cdnBranch")));
|
|
|
model.addAttribute("releaseWorkJob_project",releaseWorkJob_project);
|
|
|
model.addAttribute("releaseWorkJob_id", workJobId);
|
|
|
}
|
...
|
...
|
@@ -103,7 +106,7 @@ public class DockerBuildCtrl { |
|
|
BaseResponse response=httpRestClient.defaultGet("/dockerProject/getDockerProjectMapByIds", BaseResponse.class, mapIds);
|
|
|
Map projectMap=JSON.parseObject((String)response.getData(),Map.class);
|
|
|
|
|
|
if("deploy".equalsIgnoreCase(operate_name)){
|
|
|
if("deploy".equalsIgnoreCase(operate_name)&&"git".equals(project_deploy_type)){
|
|
|
for(String buildIdWithProjectId:buildIds.split(",")){
|
|
|
int index = buildIdWithProjectId.indexOf("-");
|
|
|
String projectId=buildIdWithProjectId.substring(0,index);
|
...
|
...
|
@@ -116,6 +119,7 @@ public class DockerBuildCtrl { |
|
|
buildInfoList.add(map);
|
|
|
}
|
|
|
}else{
|
|
|
//回滚 或者 镜像文件发布
|
|
|
String projectId=project_id;
|
|
|
Map map=new HashMap();
|
|
|
map.put("projectId",projectId);
|
...
|
...
|
@@ -136,6 +140,7 @@ public class DockerBuildCtrl { |
|
|
model.addAttribute("clusters_text", clusters_text);
|
|
|
model.addAttribute("operate_name", operate_name);
|
|
|
model.addAttribute("branch_name", branch_name);
|
|
|
model.addAttribute("project_deploy_type", project_deploy_type);
|
|
|
model.addAttribute("image_file_name", image_file_name);
|
|
|
model.addAttribute("workid_name", workid_name);
|
|
|
model.addAttribute("rollbackfile_name", rollbackImageStore);
|
...
|
...
|
@@ -251,13 +256,13 @@ public class DockerBuildCtrl { |
|
|
**/
|
|
|
@RequestMapping(value = "/rollback")
|
|
|
@ResponseBody
|
|
|
public BaseResponse rollback(String project_id, String environment_name, String clusters_name,String rollbackImageStore){
|
|
|
public BaseResponse deployByImageStore(String project_id, String environment_name, String clusters_name,String rollbackImageStore){
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
map.put("projectId", project_id);
|
|
|
map.put("environment", environment_name);
|
|
|
map.put("clusters_name", clusters_name);
|
|
|
map.put("rollbackImageStore", rollbackImageStore);
|
|
|
return httpRestClient.defaultGet("/dockerProject/rollback", BaseResponse.class, map);
|
|
|
return httpRestClient.defaultGet(HttpUriContants.DOCKER_DEPLOY_ROLLBACK_BY_IMAGE, BaseResponse.class, map);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -268,12 +273,32 @@ public class DockerBuildCtrl { |
|
|
@RequestMapping(value = "/mirrorAndDeploy")
|
|
|
@ResponseBody
|
|
|
public BaseResponse mirrorAndDeploy(String project_id, String project_name,
|
|
|
String environment_name,String clusters_name, String operate_name,String project_deploy_type, String branch_name,String image_file_name,
|
|
|
String rollbackfile_name,String workid_name, Model model, HttpSession session) {
|
|
|
DockerJenkinsReq dockerJenkinsReq=new DockerJenkinsReq();
|
|
|
String environment_name,String clusters_name, String operate_name,String project_deploy_type,
|
|
|
String branch_name,String image_file_name,
|
|
|
String rollbackfile_name,String workid_name,int uploadCDN,String cdnBranch, Model model, HttpSession session) {
|
|
|
User user = (User) session.getAttribute("user");
|
|
|
dockerJenkinsReq.setUserName(user.getName());
|
|
|
dockerJenkinsReq.setUserMail(user.getEmail());
|
|
|
String userName=user.getName();
|
|
|
String userEmail=user.getEmail();
|
|
|
if("image".equals(project_deploy_type)){
|
|
|
if(1==uploadCDN){
|
|
|
//发布异步任务
|
|
|
CompletableFuture.runAsync(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
Map<String,String> param=new HashMap<>();
|
|
|
param.put("projectId",project_id);
|
|
|
param.put("cdnBranch",cdnBranch);
|
|
|
param.put("workid_name",workid_name);
|
|
|
param.put("operatorEmail",userEmail);
|
|
|
httpRestClient.defaultGet("/dockerProject/uploadCDN",BaseResponse.class,param);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
return deployByImageStore(project_id,environment_name,clusters_name,image_file_name);
|
|
|
}
|
|
|
DockerJenkinsReq dockerJenkinsReq=new DockerJenkinsReq();
|
|
|
dockerJenkinsReq.setUserName(userName);
|
|
|
dockerJenkinsReq.setUserMail(userEmail);
|
|
|
dockerJenkinsReq.setProjectIds(project_id);
|
|
|
dockerJenkinsReq.setNodeEnv(environment_name);
|
|
|
dockerJenkinsReq.setClusterId(clusters_name);
|
...
|
...
|
|