Authored by qinchao

docker发布

@@ -14,7 +14,7 @@ public class DockerJenkinsReq { @@ -14,7 +14,7 @@ public class DockerJenkinsReq {
14 private String userName; 14 private String userName;
15 private String userMail; 15 private String userMail;
16 private String releaseWorkId; 16 private String releaseWorkId;
17 - private String projectType; 17 + private String projectJobType;
18 18
19 //docker qlcoud 19 //docker qlcoud
20 private String clusterId; 20 private String clusterId;
@@ -9,7 +9,7 @@ public class DockerProjectModel { @@ -9,7 +9,7 @@ public class DockerProjectModel {
9 private String projectName; 9 private String projectName;
10 10
11 //项目类型 11 //项目类型
12 - private String projectType; 12 + private String projectJobType;
13 13
14 private String dockerProjectName; 14 private String dockerProjectName;
15 15
@@ -18,5 +18,5 @@ public interface DockerProjectMapper { @@ -18,5 +18,5 @@ public interface DockerProjectMapper {
18 18
19 List<DockerProjectModel> selectByIdList(@Param("idList") List<Integer> idList); 19 List<DockerProjectModel> selectByIdList(@Param("idList") List<Integer> idList);
20 20
21 - List<DockerProjectModel> selectByProjectType(@Param("projectType") String projectType); 21 + List<DockerProjectModel> selectByProjectJobType(@Param("projectJobType") String projectJobType);
22 } 22 }
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 <resultMap id="BaseResultMap" type="com.model.DockerProjectModel" > 4 <resultMap id="BaseResultMap" type="com.model.DockerProjectModel" >
5 <id column="id" property="id" jdbcType="INTEGER" /> 5 <id column="id" property="id" jdbcType="INTEGER" />
6 <result column="projectname" property="projectName" jdbcType="VARCHAR" /> 6 <result column="projectname" property="projectName" jdbcType="VARCHAR" />
7 - <result column="projecttype" property="projectType" jdbcType="VARCHAR" /> 7 + <result column="projectjobtype" property="projectJobType" jdbcType="VARCHAR" />
8 <result column="dockerprojectname" property="dockerProjectName" jdbcType="VARCHAR" /> 8 <result column="dockerprojectname" property="dockerProjectName" jdbcType="VARCHAR" />
9 <result column="dockergrayclusterid" property="dockerGrayClusterId" jdbcType="VARCHAR" /> 9 <result column="dockergrayclusterid" property="dockerGrayClusterId" jdbcType="VARCHAR" />
10 <result column="dockergraynamespace" property="dockerGrayNameSpace" jdbcType="VARCHAR" /> 10 <result column="dockergraynamespace" property="dockerGrayNameSpace" jdbcType="VARCHAR" />
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 </resultMap> 14 </resultMap>
15 15
16 <sql id="Base_Column_List" > 16 <sql id="Base_Column_List" >
17 - id, projectname,projecttype,dockerprojectName,dockergrayclusterid,dockergraynamespace,dockeronlineclusterid,dockeronlinenamespace 17 + id, projectname,projectjobtype,dockerprojectName,dockergrayclusterid,dockergraynamespace,dockeronlineclusterid,dockeronlinenamespace
18 </sql> 18 </sql>
19 19
20 <select id="selectCount" resultType="java.lang.Integer"> 20 <select id="selectCount" resultType="java.lang.Integer">
@@ -28,8 +28,8 @@ @@ -28,8 +28,8 @@
28 <include refid="Base_Column_List" /> 28 <include refid="Base_Column_List" />
29 from docker_project 29 from docker_project
30 where 1=1 30 where 1=1
31 - <if test="params.projectType != null" >  
32 - and projecttype = #{params.projectType} 31 + <if test="params.projectJobType != null" >
  32 + and projectjobtype = #{params.projectJobType}
33 </if> 33 </if>
34 order by id desc 34 order by id desc
35 limit #{startIndex},#{pageSize} 35 limit #{startIndex},#{pageSize}
@@ -43,14 +43,14 @@ @@ -43,14 +43,14 @@
43 id = #{id} 43 id = #{id}
44 </select> 44 </select>
45 45
46 - <select id="selectByProjectType" resultMap="BaseResultMap"> 46 + <select id="selectByProjectJobType" resultMap="BaseResultMap">
47 select 47 select
48 <include refid="Base_Column_List" /> 48 <include refid="Base_Column_List" />
49 from docker_project 49 from docker_project
50 where 1=1 50 where 1=1
51 <choose> 51 <choose>
52 - <when test="projectType != null &amp;&amp; projectType !='' " >  
53 - and projecttype = #{projectType} 52 + <when test="projectJobType != null &amp;&amp; projectJobType !='' " >
  53 + and projectjobtype = #{projectJobType}
54 </when> 54 </when>
55 <otherwise> 55 <otherwise>
56 and 1=2 56 and 1=2
@@ -31,10 +31,10 @@ public class DockerProjectCtrl { @@ -31,10 +31,10 @@ public class DockerProjectCtrl {
31 /** 31 /**
32 * 查询docker项目 32 * 查询docker项目
33 */ 33 */
34 - @RequestMapping("/getDockerProjectByType") 34 + @RequestMapping("/getDockerProjectByJobType")
35 @ResponseBody 35 @ResponseBody
36 - public BaseResponse<List<DockerProjectModel>> getDockerProjectByType(String projectType) {  
37 - return new BaseResponse<>(dockerProjectService.selectByProjectType(projectType)); 36 + public BaseResponse<List<DockerProjectModel>> getDockerProjectByJobType(String projectJobType) {
  37 + return new BaseResponse<>(dockerProjectService.selectByProjectJobType(projectJobType));
38 } 38 }
39 39
40 /** 40 /**
1 package com.monitor.other.worksystem.dock; 1 package com.monitor.other.worksystem.dock;
2 2
3 -import com.alibaba.fastjson.JSON;  
4 import com.offbytwo.jenkins.JenkinsServer; 3 import com.offbytwo.jenkins.JenkinsServer;
5 -import com.offbytwo.jenkins.model.Build;  
6 import com.offbytwo.jenkins.model.Job; 4 import com.offbytwo.jenkins.model.Job;
7 import com.offbytwo.jenkins.model.JobWithDetails; 5 import com.offbytwo.jenkins.model.JobWithDetails;
8 -import com.offbytwo.jenkins.model.QueueItem;  
9 6
10 import java.net.URI; 7 import java.net.URI;
11 import java.util.Map; 8 import java.util.Map;
12 9
13 10
14 public class FastJenkinsUtils { 11 public class FastJenkinsUtils {
15 - public final static String JENKINS_JOB_JAVA="Docker-Deploy-Java";  
16 - public final static String JENKINS_JOB_NODE="Docker-Deploy-Node";  
17 12
18 private final String JENKINS_SERVER_URI="http://140.143.118.227/"; 13 private final String JENKINS_SERVER_URI="http://140.143.118.227/";
19 private final String JENKINS_SERVER_USER="yoho"; 14 private final String JENKINS_SERVER_USER="yoho";
@@ -15,7 +15,7 @@ import java.util.List; @@ -15,7 +15,7 @@ import java.util.List;
15 public interface DockerProjectService { 15 public interface DockerProjectService {
16 List<DockerProjectModel> selectByIdList(List<Integer> idList); 16 List<DockerProjectModel> selectByIdList(List<Integer> idList);
17 17
18 - List<DockerProjectModel> selectByProjectType(String projectType); 18 + List<DockerProjectModel> selectByProjectJobType(String projectJobType);
19 19
20 String jenkinsBuild(DockerJenkinsReq dockerJenkinsReq); 20 String jenkinsBuild(DockerJenkinsReq dockerJenkinsReq);
21 21
@@ -40,11 +40,11 @@ public class DockerProjectServiceImpl implements DockerProjectService { @@ -40,11 +40,11 @@ public class DockerProjectServiceImpl implements DockerProjectService {
40 return dockerProjectMapper.selectByIdList(idList); 40 return dockerProjectMapper.selectByIdList(idList);
41 } 41 }
42 42
43 - public List<DockerProjectModel> selectByProjectType(String projectType){  
44 - if(StringUtils.isBlank(projectType)){ 43 + public List<DockerProjectModel> selectByProjectJobType(String projectJobType){
  44 + if(StringUtils.isBlank(projectJobType)){
45 return new ArrayList<>(); 45 return new ArrayList<>();
46 } 46 }
47 - return dockerProjectMapper.selectByProjectType(projectType); 47 + return dockerProjectMapper.selectByProjectJobType(projectJobType);
48 } 48 }
49 49
50 @Override 50 @Override
@@ -66,12 +66,7 @@ public class DockerProjectServiceImpl implements DockerProjectService { @@ -66,12 +66,7 @@ public class DockerProjectServiceImpl implements DockerProjectService {
66 dockerJenkinsRecordMapper.insert(record); 66 dockerJenkinsRecordMapper.insert(record);
67 67
68 FastJenkinsUtils fastJenkinsUtils=new FastJenkinsUtils(); 68 FastJenkinsUtils fastJenkinsUtils=new FastJenkinsUtils();
69 - String jobName="";  
70 - if("NODE".equalsIgnoreCase(dockerJenkinsReq.getProjectType())){  
71 - jobName=FastJenkinsUtils.JENKINS_JOB_NODE;  
72 - }else if("JAVA".equalsIgnoreCase(dockerJenkinsReq.getProjectType())){  
73 - jobName=FastJenkinsUtils.JENKINS_JOB_JAVA;  
74 - } 69 + String jobName=dockerJenkinsReq.getProjectJobType();
75 fastJenkinsUtils.createJob(jobName,params); 70 fastJenkinsUtils.createJob(jobName,params);
76 }catch (Exception e){ 71 }catch (Exception e){
77 logger.error("jenkinsBuild error",e); 72 logger.error("jenkinsBuild error",e);