...
|
...
|
@@ -66,7 +66,7 @@ public class WorkSystemCtrl { |
|
|
model.addAttribute("projectDeployTypes", ProjectEnvironment.getProjectDeployTypeMap());
|
|
|
BaseResponse<List<User>> resp = httpRestClient.exchangeForget(HttpUriContants.GET_All_USER, new ParameterizedTypeReference<BaseResponse<List<User>>>() {
|
|
|
}, null);
|
|
|
model.addAttribute("verifiers",resp.getData());//审核人列表
|
|
|
model.addAttribute("verifiers", resp.getData());//审核人列表
|
|
|
BaseResponse<List<User>> response = httpRestClient.exchangeForget(HttpUriContants.GET_USER_BY_ROLE + "?role=test", new ParameterizedTypeReference<BaseResponse<List<User>>>() {
|
|
|
}, null);
|
|
|
model.addAttribute("tests", response.getData());
|
...
|
...
|
@@ -97,14 +97,15 @@ public class WorkSystemCtrl { |
|
|
int count = 0;
|
|
|
if (isHandler.getData() != null) {
|
|
|
count = 1;
|
|
|
model.addAttribute("pendingJob",isHandler.getData());
|
|
|
model.addAttribute("pendingJob", isHandler.getData());
|
|
|
}
|
|
|
model.addAttribute("count", count);
|
|
|
if ("release".equals(type)) {
|
|
|
BaseResponse response = httpRestClient.defaultGet(HttpUriContants.GET_RELEASEWORKJOB_ID + "?id=" + workid, BaseResponse.class);
|
|
|
model.addAttribute("workJob", response.getData());
|
|
|
return new ModelAndView("worksystem/releaseWork");
|
|
|
}else if ("db".equals(type)){
|
|
|
}
|
|
|
if ("db".equals(type)) {
|
|
|
BaseResponse<List<User>> response = httpRestClient.exchangeForget(HttpUriContants.GET_USER_BY_ROLE + "?role=test", new ParameterizedTypeReference<BaseResponse<List<User>>>() {
|
|
|
}, null);
|
|
|
model.addAttribute("tests", response.getData());
|
...
|
...
|
@@ -112,28 +113,33 @@ public class WorkSystemCtrl { |
|
|
model.addAttribute("workJob", response2.getData());
|
|
|
return new ModelAndView("worksystem/dbWork");
|
|
|
}
|
|
|
if ("config".equals(type)) {
|
|
|
BaseResponse response3 = httpRestClient.defaultGet(HttpUriContants.GET_CONFIG_WORKJOB_ID + "?id=" + workid, BaseResponse.class);
|
|
|
model.addAttribute("workJob", response3.getData());
|
|
|
return new ModelAndView("worksystem/configWork");
|
|
|
}
|
|
|
|
|
|
return new ModelAndView("worksystem/workList");
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/getProjectsByPlatform")
|
|
|
@ResponseBody
|
|
|
public List<Project> getProjectsByPlatform(String platform,String projectType) {
|
|
|
public List<Project> getProjectsByPlatform(String platform, String projectType) {
|
|
|
if (Platform.JAVA.equals(platform)) {
|
|
|
return projectsLoader.getProjectOnline().getJavaList();
|
|
|
} else if (Platform.PHP.equals(platform)) {
|
|
|
String result = httpRestClient.get("http://"+ ProjectConstant.DEPLOY_IP+":8883/php/getProjects", String.class, null);
|
|
|
return JSON.parseObject(result,List.class);
|
|
|
String result = httpRestClient.get("http://" + ProjectConstant.DEPLOY_IP + ":8883/php/getProjects", String.class, null);
|
|
|
return JSON.parseObject(result, List.class);
|
|
|
} else if (Platform.NODE.equals(platform)) {
|
|
|
String result = nodeBuildCtrl.getProjects();
|
|
|
return JSON.parseObject(result,List.class);
|
|
|
}else if (Platform.DOCKER.equals(platform)) {
|
|
|
BaseResponse response=dockerBuildCtrl.getDockerProjectsByType(projectType);
|
|
|
List<DockerProjectModel> models=JSONArray.parseArray(JSONArray.toJSON(response.getData()).toString(),DockerProjectModel.class);
|
|
|
List<Project> ls=new LinkedList<>();
|
|
|
if(models!=null&&models.size()>0){
|
|
|
for(DockerProjectModel model:models){
|
|
|
Project pro=new Project();
|
|
|
return JSON.parseObject(result, List.class);
|
|
|
} else if (Platform.DOCKER.equals(platform)) {
|
|
|
BaseResponse response = dockerBuildCtrl.getDockerProjectsByType(projectType);
|
|
|
List<DockerProjectModel> models = JSONArray.parseArray(JSONArray.toJSON(response.getData()).toString(), DockerProjectModel.class);
|
|
|
List<Project> ls = new LinkedList<>();
|
|
|
if (models != null && models.size() > 0) {
|
|
|
for (DockerProjectModel model : models) {
|
|
|
Project pro = new Project();
|
|
|
pro.setName(model.getProjectName());
|
|
|
pro.setDockerProjectModelId(model.getId());
|
|
|
pro.setSupportDeployType(model.getSupportDeployType());
|
...
|
...
|
@@ -149,58 +155,58 @@ public class WorkSystemCtrl { |
|
|
@RequestMapping(value = "getDeployImageList")
|
|
|
@ResponseBody
|
|
|
public String getDeployImageList(String projectId, String environment) {
|
|
|
return dockerBuildCtrl.getDeployImageList(projectId,environment);
|
|
|
return dockerBuildCtrl.getDeployImageList(projectId, environment);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "getEnvByProject")
|
|
|
@ResponseBody
|
|
|
public List<String> getEnvByProject(String platform ,String projects) {
|
|
|
List<String> projArray=new ArrayList<>();
|
|
|
for(String tmp:projects.split(",")){
|
|
|
if(StringUtils.isNotBlank(tmp)){
|
|
|
public List<String> getEnvByProject(String platform, String projects) {
|
|
|
List<String> projArray = new ArrayList<>();
|
|
|
for (String tmp : projects.split(",")) {
|
|
|
if (StringUtils.isNotBlank(tmp)) {
|
|
|
projArray.add(tmp);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
List<String> envs=new ArrayList<>();
|
|
|
if(StringUtils.isBlank(platform)||StringUtils.isBlank(projects)||projArray.size()<=0){
|
|
|
List<String> envs = new ArrayList<>();
|
|
|
if (StringUtils.isBlank(platform) || StringUtils.isBlank(projects) || projArray.size() <= 0) {
|
|
|
return envs;
|
|
|
}
|
|
|
|
|
|
if (Platform.JAVA.equals(platform)) {
|
|
|
envs.addAll(projectBuildCtrl.getJavaProjectEnvList(projArray));
|
|
|
} else if (Platform.NODE.equals(platform)||Platform.PHP.equals(platform)) {
|
|
|
for(int i=0;i<projArray.size();i++){
|
|
|
List<String> ls= getProjectEnvByName(platform,projArray.get(i));
|
|
|
if(i==0){
|
|
|
} else if (Platform.NODE.equals(platform) || Platform.PHP.equals(platform)) {
|
|
|
for (int i = 0; i < projArray.size(); i++) {
|
|
|
List<String> ls = getProjectEnvByName(platform, projArray.get(i));
|
|
|
if (i == 0) {
|
|
|
envs.addAll(ls);
|
|
|
}else{
|
|
|
} else {
|
|
|
envs.retainAll(ls);
|
|
|
}
|
|
|
}
|
|
|
}else if (Platform.DOCKER.equals(platform)) {
|
|
|
} else if (Platform.DOCKER.equals(platform)) {
|
|
|
envs.addAll(ProjectEnvironment.getDockerEnvironments(projects));
|
|
|
}
|
|
|
return envs;
|
|
|
}
|
|
|
|
|
|
|
|
|
public List<String> getProjectEnvByName(String platform ,String project) {
|
|
|
List<String> ls=new ArrayList<>();
|
|
|
String jsonProjectDesc="";
|
|
|
if(Platform.PHP.equals(platform)){
|
|
|
jsonProjectDesc=phpBuildCtrl.getProjectByName(project);
|
|
|
public List<String> getProjectEnvByName(String platform, String project) {
|
|
|
List<String> ls = new ArrayList<>();
|
|
|
String jsonProjectDesc = "";
|
|
|
if (Platform.PHP.equals(platform)) {
|
|
|
jsonProjectDesc = phpBuildCtrl.getProjectByName(project);
|
|
|
} else if (Platform.NODE.equals(platform)) {
|
|
|
jsonProjectDesc=nodeBuildCtrl.getProjectByName(project);
|
|
|
jsonProjectDesc = nodeBuildCtrl.getProjectByName(project);
|
|
|
}
|
|
|
|
|
|
if(StringUtils.isNotBlank(jsonProjectDesc)&&!"failed".equals(jsonProjectDesc)){
|
|
|
JSONObject jo= JSON.parseObject(jsonProjectDesc);
|
|
|
if(jo!=null&&jo.getJSONArray("envs")!=null){
|
|
|
JSONArray ja=jo.getJSONArray("envs");
|
|
|
for(int i=0;i<ja.size();i++){
|
|
|
String evnName=ja.getJSONObject(i).getString("name");
|
|
|
if(StringUtils.isNotBlank(evnName)){
|
|
|
if (StringUtils.isNotBlank(jsonProjectDesc) && !"failed".equals(jsonProjectDesc)) {
|
|
|
JSONObject jo = JSON.parseObject(jsonProjectDesc);
|
|
|
if (jo != null && jo.getJSONArray("envs") != null) {
|
|
|
JSONArray ja = jo.getJSONArray("envs");
|
|
|
for (int i = 0; i < ja.size(); i++) {
|
|
|
String evnName = ja.getJSONObject(i).getString("name");
|
|
|
if (StringUtils.isNotBlank(evnName)) {
|
|
|
ls.add(evnName);
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -217,7 +223,7 @@ public class WorkSystemCtrl { |
|
|
if ("release".equals(type)) {//项目发布
|
|
|
BaseResponse<Integer> baseResponse = httpRestClient.defaultGet(HttpUriContants.CHECK_RELEASE_ROLE + "?role=" + user.getRole(), BaseResponse.class);
|
|
|
return baseResponse.getData();
|
|
|
}else if ("db".equals(type)){
|
|
|
} else if ("db".equals(type)) {
|
|
|
BaseResponse<Integer> baseResponse = httpRestClient.defaultGet(HttpUriContants.CHECK_DB_ROLE + "?role=" + user.getRole(), BaseResponse.class);
|
|
|
return baseResponse.getData();
|
|
|
}
|
...
|
...
|
@@ -230,23 +236,23 @@ public class WorkSystemCtrl { |
|
|
User user = (User) session.getAttribute("user");
|
|
|
releaseWorkJob.setDevelop(user.getName());
|
|
|
releaseWorkJob.setProject(releaseWorkJob.getProject().substring(1));
|
|
|
if(StringUtils.isNotBlank(releaseWorkJob.getTestProject()) && releaseWorkJob.getTestProject().length() > 1){
|
|
|
if (StringUtils.isNotBlank(releaseWorkJob.getTestProject()) && releaseWorkJob.getTestProject().length() > 1) {
|
|
|
releaseWorkJob.setTestProject(releaseWorkJob.getTestProject().substring(1));
|
|
|
}
|
|
|
if (Platform.JAVA.equals(releaseWorkJob.getPlatform())) {
|
|
|
List<Object> checkRtn=ProjectMutex.checkMutex(releaseWorkJob.getProject());
|
|
|
boolean mutex=(Boolean)checkRtn.get(0);
|
|
|
if(mutex){
|
|
|
List<Object> checkRtn = ProjectMutex.checkMutex(releaseWorkJob.getProject());
|
|
|
boolean mutex = (Boolean) checkRtn.get(0);
|
|
|
if (mutex) {
|
|
|
//存在互斥的项目
|
|
|
BaseResponse baseResponse = new BaseResponse();
|
|
|
baseResponse.setCode(200);
|
|
|
baseResponse.setData(-1);
|
|
|
baseResponse.setMessage((String)checkRtn.get(1));
|
|
|
baseResponse.setMessage((String) checkRtn.get(1));
|
|
|
return baseResponse;
|
|
|
}
|
|
|
}else if (Platform.NODE.equals(releaseWorkJob.getPlatform())) {
|
|
|
if(releaseWorkJob.getEnvironment().contains("az1")){
|
|
|
if(!"master".equals(releaseWorkJob.getBranch())){
|
|
|
} else if (Platform.NODE.equals(releaseWorkJob.getPlatform())) {
|
|
|
if (releaseWorkJob.getEnvironment().contains("az1")) {
|
|
|
if (!"master".equals(releaseWorkJob.getBranch())) {
|
|
|
BaseResponse baseResponse = new BaseResponse();
|
|
|
baseResponse.setCode(200);
|
|
|
baseResponse.setData(-1);
|
...
|
...
|
@@ -269,11 +275,11 @@ public class WorkSystemCtrl { |
|
|
@ResponseBody
|
|
|
public BaseResponse callbackTest(String testId, String testMessage) {
|
|
|
BaseResponse baseResponse = new BaseResponse();
|
|
|
if(StringUtils.isBlank(testId) || StringUtils.isBlank(testMessage)){
|
|
|
if (StringUtils.isBlank(testId) || StringUtils.isBlank(testMessage)) {
|
|
|
baseResponse.setCode(201);
|
|
|
baseResponse.setMessage("testId 且 testMessage 不能为空!");
|
|
|
}else{
|
|
|
baseResponse = httpRestClient.defaultPost(HttpUriContants.CREATE_CALLBACKTEST+"?testId="+testId+"&testMessage="+testMessage, null, BaseResponse.class);
|
|
|
} else {
|
|
|
baseResponse = httpRestClient.defaultPost(HttpUriContants.CREATE_CALLBACKTEST + "?testId=" + testId + "&testMessage=" + testMessage, null, BaseResponse.class);
|
|
|
}
|
|
|
return baseResponse;
|
|
|
}
|
...
|
...
|
@@ -283,16 +289,27 @@ public class WorkSystemCtrl { |
|
|
public BaseResponse createDBWorkJob(@RequestBody DBWorkJob dbWorkJob, HttpSession session) {
|
|
|
User user = (User) session.getAttribute("user");
|
|
|
dbWorkJob.setDevelop(user.getName());
|
|
|
BaseResponse<Integer> baseResponse =null;
|
|
|
if(dbWorkJob.getText()!=null&&dbWorkJob.getText().length()>5000){
|
|
|
baseResponse=new BaseResponse<Integer>(-2);
|
|
|
BaseResponse<Integer> baseResponse = null;
|
|
|
if (dbWorkJob.getText() != null && dbWorkJob.getText().length() > 5000) {
|
|
|
baseResponse = new BaseResponse<Integer>(-2);
|
|
|
baseResponse.setCode(201);
|
|
|
baseResponse.setMessage("SQL内容过长,一次不要超过5000字符");
|
|
|
}else{
|
|
|
} else {
|
|
|
baseResponse = httpRestClient.defaultPost(HttpUriContants.CREATE_DBWORKJOB, dbWorkJob, BaseResponse.class);
|
|
|
}
|
|
|
return baseResponse;
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/createConfigWorkJob")
|
|
|
@ResponseBody
|
|
|
public BaseResponse createConfigWorkJob(@RequestBody ConfigWorkJob configWorkJob, HttpSession session) {
|
|
|
User user = (User) session.getAttribute("user");
|
|
|
configWorkJob.setDevelop(user.getName());
|
|
|
BaseResponse<Integer> baseResponse = null;
|
|
|
baseResponse = httpRestClient.defaultPost(HttpUriContants.CREATE_CONFIG_WORKJOB, configWorkJob, BaseResponse.class);
|
|
|
return baseResponse;
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/getHandledJobs")
|
|
|
@ResponseBody
|
|
|
public BaseResponse getHandledJobs(HttpSession session, PageRequest req) {
|
...
|
...
|
|