Authored by qinchao

docker发布

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