Authored by qinchao

docker工单系统的发布

... ... @@ -83,4 +83,9 @@ public class ReleaseWorkJob {
private String updateTime;
/**
* 项目类别,现在只是记录docker类型的工单的项目的归属列表
*/
private String projectType;
}
... ...
... ... @@ -20,7 +20,7 @@ public class Platform {
list.add("JAVA");
list.add("PHP");
list.add("NODE");
//list.add("DOCKER");
list.add("DOCKER");
}
public static List<String> getPlatforms(){
... ...
... ... @@ -8,7 +8,6 @@ public class ProjectOnline {
private static List<Project> JAVA_LIST = new ArrayList<Project>();
private static List<Project> PHP_LIST = new ArrayList<Project>();
private static List<Project> NODE_LIST = new ArrayList<Project>();
private static List<Project> DOCKER_LIST = new ArrayList<Project>();
static{
JAVA_LIST.add(new Project("1","yoho-sns","125","yoho30"));
... ... @@ -85,9 +84,6 @@ public class ProjectOnline {
NODE_LIST.add(new Project("","yohobuy-shop","",""));
NODE_LIST.add(new Project("","yoho-shop-manage","",""));
DOCKER_LIST.add(new Project("","yohoblk-wap","",""));
DOCKER_LIST.add(new Project("","yohoblk-wap2","",""));
}
... ... @@ -95,10 +91,6 @@ public class ProjectOnline {
return JAVA_LIST;
}
public static List<Project> getDockerList() {
return DOCKER_LIST;
}
public static List<Project> getPhpList() {
return PHP_LIST;
}
... ...
... ... @@ -37,7 +37,31 @@ public class DockerBuildCtrl {
public ModelAndView toProject(Model model,String workJobId) {
if(StringUtils.isNotBlank(workJobId)){
//如果来源工单发布界面
BaseResponse response = httpRestClient.defaultGet(HttpUriContants.GET_RELEASEWORKJOB_ID + "?id=" + workJobId, BaseResponse.class);
if(response!=null&&response.getCode()==200&&response.getData()!=null){
Map map=(Map)response.getData();
String releaseWorkJob_environment=(String)(map.get("environment")==null?"":map.get("environment"));
//int releaseWorkJob_enviCount=0;
if(releaseWorkJob_environment!=null&&releaseWorkJob_environment.length()>0&&!releaseWorkJob_environment.endsWith(",")){
releaseWorkJob_environment+=",";
}
/* for(String tmp:releaseWorkJob_environment.split(",")){
if(tmp!=null&&tmp.length()>0){
releaseWorkJob_enviCount++;
}
}*/
String releaseWorkJob_project = map.get("project")==null?"":(String)map.get("project");
if(releaseWorkJob_project!=null&&releaseWorkJob_project.length()>0&&!releaseWorkJob_project.endsWith(",")){
releaseWorkJob_project += ",";
}
//model.addAttribute("releaseWorkJob_enviCount", releaseWorkJob_enviCount);
model.addAttribute("releaseWorkJob_environment", releaseWorkJob_environment);
model.addAttribute("releaseWorkJob_projectType", map.get("projectType")==null?"":(String)map.get("projectType"));
model.addAttribute("releaseWorkJob_branch", map.get("branch")==null?"":(String)map.get("branch"));
model.addAttribute("releaseWorkJob_project",releaseWorkJob_project);
model.addAttribute("releaseWorkJob_id", workJobId);
}
}
model.addAttribute("environments", ProjectEnvironment.getDockerEnvironments());
model.addAttribute("projectTypes", ProjectEnvironment.getDockerProjectTypeMap());
... ...
package com.ui.ctrl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.ui.contants.HttpUriContants;
import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
import com.ui.model.domain.DockerProjectModel;
import com.ui.model.req.*;
import com.ui.project.Platform;
import com.ui.project.Project;
... ... @@ -22,7 +24,10 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* Created by zhengyouwei on 2016/9/5.
... ... @@ -42,6 +47,8 @@ public class WorkSystemCtrl {
model.addAttribute("platforms", Platform.getPlatforms());
model.addAttribute("environments", ProjectEnvironment.getEnviroments());
model.addAttribute("dockerEnvironments", ProjectEnvironment.getDockerEnvironments());
model.addAttribute("projectTypes", ProjectEnvironment.getDockerProjectTypeMap());
BaseResponse<List<User>> resp = httpRestClient.exchangeForget(HttpUriContants.GET_All_USER, new ParameterizedTypeReference<BaseResponse<List<User>>>() {
}, null);
model.addAttribute("verifiers",resp.getData());//审核人列表
... ... @@ -96,7 +103,7 @@ public class WorkSystemCtrl {
@RequestMapping("/getProjectsByPlatform")
@ResponseBody
public List<Project> getProjectsByPlatform(String platform) {
public List<Project> getProjectsByPlatform(String platform,String projectType) {
if (Platform.JAVA.equals(platform)) {
return ProjectOnline.getJavaList();
} else if (Platform.PHP.equals(platform)) {
... ... @@ -106,7 +113,19 @@ public class WorkSystemCtrl {
String result = httpRestClient.get("http://172.31.16.167:8883/node/getProjects", String.class, null);
return JSON.parseObject(result,List.class);
}else if (Platform.DOCKER.equals(platform)) {
return ProjectOnline.getDockerList();
Map map = new HashMap<>();
map.put("projectType",projectType);
BaseResponse response=httpRestClient.defaultGet("/dockerProject/getDockerProjectByProjectType", BaseResponse.class, map);
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());
ls.add(pro);
}
}
return ls;
}
return null;
}
... ...
... ... @@ -85,7 +85,17 @@
<div class="rdio rdio-default" style='display: inline'>
<input type="radio" name="projectTypes" id="${projType.key }" value="${projType.key }"
onclick="getProjects()"
<c:if test="${projTypeStatus.index==0}">checked="checked"</c:if>
<c:choose>
<c:when test="${releaseWorkJob_projectType!=null}">
<c:if test="${fn:containsIgnoreCase(releaseWorkJob_projectType,projType.key)}">checked="checked"</c:if>
</c:when>
<c:otherwise>
<c:if test="${projTypeStatus.index==0}">checked="checked"</c:if>
</c:otherwise>
</c:choose>
/>
<label for="${projType.key }">${projType.value }</label>&nbsp;&nbsp;&nbsp;
</div>
... ...
... ... @@ -88,11 +88,40 @@
<div class="form-group">
<label class="col-sm-1 control-label"><strong>环境选择: </strong></label>
<div class="col-sm-8">
<c:forEach items="${environments }" var="environment">
<div id="environmentDiv_common">
<c:forEach items="${environments }" var="environment">
<div class="ckbox ckbox-default" style="display: inline">
<input type="checkbox" name="environment" id="${environment}"
value="${environment}"/>
<label for="${environment}" style='width: 100px'>${environment}</label>
</div>
</c:forEach>
</div>
<div id="environmentDiv_docker" style="display: none">
<div class="ckbox ckbox-default" style="display: inline">
<input type="checkbox" name="environment" id="${environment}"
value="${environment}"/>
<label for="${environment}" style='width: 100px'>${environment}</label>
<c:forEach items="${dockerEnvironments }" var="environment">
<div class="ckbox ckbox-default" style="display: inline">
<input type="checkbox" name="environment" id="docker_environment_${environment}"
value="${environment}"/>
<label for="docker_environment_${environment}" style='width: 100px'>${environment}</label>
</div>
</c:forEach>
</div>
</div>
</div>
</div>
<div id="projectTypesDiv" class="form-group" style="display: none">
<label class="col-sm-1 control-label"><strong>项目类别: </strong></label>
<div class="col-sm-8">
<c:forEach items="${projectTypes }" var="projType" varStatus="projTypeStatus">
<div class="rdio rdio-default" style='display: inline'>
<input type="radio" name="projectTypes" id="projectType_${projType.key }" value="${projType.key }"
onclick="changePlatform()"
<c:if test="${projTypeStatus.index==0}">checked="checked"</c:if>
/>
<label for="projectType_${projType.key }">${projType.value }</label>&nbsp;&nbsp;&nbsp;
</div>
</c:forEach>
</div>
... ... @@ -248,8 +277,21 @@
function changePlatform() {
var platform = $('input:radio[name=platform]:checked').val();
var projectType=$("input[name='projectTypes']:checked").val();
var getProjectUrl=contextPath + 'workSystem/getProjectsByPlatform?platform='+platform;
if("DOCKER" == platform){
$("#environmentDiv_common").hide();
$("#environmentDiv_docker").show();
$("#projectTypesDiv").show();
getProjectUrl += "&projectType="+projectType;
}else{
$("#environmentDiv_common").show();
$("#environmentDiv_docker").hide();
$("#projectTypesDiv").hide();
}
$.ajax({
url: contextPath + 'workSystem/getProjectsByPlatform?platform=' + platform,
url: getProjectUrl,
type: 'POST',
success: function (data) {
var project_HTML = "";
... ... @@ -398,6 +440,7 @@
project: project,
branch:$("#inputBranch").val(),
testProject: testProject,
projectType:$("input[name='projectTypes']:checked").val(),
test: test
};
... ...
... ... @@ -196,6 +196,9 @@
}else if("NODE"==platform){
$("#btn_release").removeAttr("disabled");
window.open(contextPath+"nodeBuild/toProject?workJobId="+workJobId);
}else if("DOCKER"==platform){
$("#btn_release").removeAttr("disabled");
window.open(contextPath+"dockerBuild/toProject?workJobId="+workJobId);
}else{
$("#btn_release").removeAttr("disabled");
alert("暂时不支持跳转:"+platform);
... ...