...
|
...
|
@@ -6,11 +6,14 @@ 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.maliciousip.ctrl.MaliciousIpController;
|
|
|
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.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
...
|
...
|
@@ -26,6 +29,9 @@ import java.util.concurrent.CompletableFuture; |
|
|
@RequestMapping("/dockerProject")
|
|
|
public class DockerProjectCtrl {
|
|
|
|
|
|
|
|
|
Logger log = LoggerFactory.getLogger(DockerProjectCtrl.class);
|
|
|
|
|
|
@Autowired
|
|
|
private DockerProjectService dockerProjectService;
|
|
|
|
...
|
...
|
@@ -85,15 +91,19 @@ public class DockerProjectCtrl { |
|
|
public BaseResponse gitWebHook(@RequestBody WebHooksReleaseBO webHooksReleaseBO) {
|
|
|
BaseResponse rtn=new BaseResponse<>();
|
|
|
if (!webHooksReleaseBO.getRef().contains("master")&&StringUtils.isBlank(webHooksReleaseBO.getProjectName())) {
|
|
|
log.info("gitWebHook 非master分支或者项目名为空");
|
|
|
return rtn;
|
|
|
}
|
|
|
|
|
|
log.info("gitWebHook begin");
|
|
|
DockerProjectModel model=dockerProjectMapper.selectByProjectName(webHooksReleaseBO.getProjectName());
|
|
|
log.info("gitWebHook model {} ",model);
|
|
|
if (isRealChange(webHooksReleaseBO)&&model!=null) {
|
|
|
//异步
|
|
|
log.info("gitWebHook isRealChange is true ");
|
|
|
CompletableFuture.runAsync(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
log.info("gitWebHook run ");
|
|
|
//Docker-Deploy-GitHook
|
|
|
DockerJenkinsReq dockerJenkinsReq=new DockerJenkinsReq();
|
|
|
dockerJenkinsReq.setDeployName(model.getProjectName());
|
...
|
...
|
@@ -103,9 +113,13 @@ public class DockerProjectCtrl { |
|
|
dockerJenkinsReq.setUserMail(webHooksReleaseBO.getUser_email());
|
|
|
dockerJenkinsReq.setImageSource(model.getDockerOnlineImageStore());
|
|
|
dockerJenkinsReq.setNodeEnv("yoho-online");
|
|
|
|
|
|
log.info("gitWebHook run {} ",dockerJenkinsReq);
|
|
|
dockerProjectService.jenkinsBuild(dockerJenkinsReq);
|
|
|
}
|
|
|
});
|
|
|
}else{
|
|
|
log.info("gitWebHook isRealChange is false ");
|
|
|
}
|
|
|
|
|
|
return rtn;
|
...
|
...
|
|