...
|
...
|
@@ -5,8 +5,11 @@ import com.model.DockerJenkinsRecord; |
|
|
import com.model.DockerProjectModel;
|
|
|
import com.monitor.model.request.DockerJenkinsReq;
|
|
|
import com.monitor.model.response.BaseResponse;
|
|
|
import com.monitor.mysql.mapper.DockerProjectMapper;
|
|
|
import com.monitor.other.worksystem.dock.qq.DockerServerDeployService;
|
|
|
import com.monitor.other.worksystem.model.WebHooksReleaseBO;
|
|
|
import com.monitor.other.worksystem.service.DockerProjectService;
|
|
|
import com.offbytwo.jenkins.model.JobWithDetails;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
...
|
...
|
@@ -28,6 +31,9 @@ public class DockerProjectCtrl { |
|
|
@Autowired
|
|
|
private DockerServerDeployService dockerServerDeployService;
|
|
|
|
|
|
@Autowired
|
|
|
private DockerProjectMapper dockerProjectMapper;
|
|
|
|
|
|
/**
|
|
|
* 查询docker项目
|
|
|
*/
|
...
|
...
|
@@ -71,6 +77,45 @@ public class DockerProjectCtrl { |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 发布工单_jenkins:自动发布的项目
|
|
|
*/
|
|
|
@RequestMapping("/gitWebHook")
|
|
|
@ResponseBody
|
|
|
public BaseResponse gitWebHook(@RequestBody WebHooksReleaseBO webHooksReleaseBO) {
|
|
|
BaseResponse rtn=new BaseResponse<>();
|
|
|
if (!webHooksReleaseBO.getRef().contains("master")&&StringUtils.isBlank(webHooksReleaseBO.getProjectName())) {
|
|
|
rtn.setData("");
|
|
|
return rtn;
|
|
|
}
|
|
|
|
|
|
DockerProjectModel model=dockerProjectMapper.selectByProjectName(webHooksReleaseBO.getProjectName());
|
|
|
if (isRealChange(webHooksReleaseBO)&&model!=null) {
|
|
|
//Docker-Deploy-GitHook
|
|
|
DockerJenkinsReq dockerJenkinsReq=new DockerJenkinsReq();
|
|
|
dockerJenkinsReq.setDeployName(model.getProjectName());
|
|
|
dockerJenkinsReq.setProjectGitGroup(model.getProjectGitGroup());
|
|
|
dockerJenkinsReq.setDeployName(model.getDockerProjectName());
|
|
|
dockerJenkinsReq.setBranch("master");
|
|
|
dockerJenkinsReq.setUserMail(webHooksReleaseBO.getUser_email());
|
|
|
dockerJenkinsReq.setImageSource(model.getDockerOnlineImageStore());
|
|
|
dockerJenkinsReq.setNodeEnv("yoho-online");
|
|
|
String id=dockerProjectService.jenkinsBuild(dockerJenkinsReq);
|
|
|
rtn.setData(id);
|
|
|
}
|
|
|
|
|
|
return rtn;
|
|
|
}
|
|
|
|
|
|
public Boolean isRealChange(WebHooksReleaseBO webHooksReleaseBO) {
|
|
|
boolean object_kind_check = webHooksReleaseBO.getObject_kind().equals("push");
|
|
|
boolean ref_check = webHooksReleaseBO.getRef().equals("refs/heads/master");
|
|
|
boolean total_commits_count_check = webHooksReleaseBO.getTotal_commits_count() > 0;
|
|
|
return object_kind_check && ref_check && total_commits_count_check;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 发布工单_jenkins:更新镜像的状态
|
|
|
*/
|
|
|
@RequestMapping("/updateJenkinsStatus")
|
...
|
...
|
|