Authored by qinchao

gitwebhook

... ... @@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
@Controller
@RequestMapping("/dockerProject")
... ... @@ -84,23 +85,27 @@ public class DockerProjectCtrl {
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);
//异步
CompletableFuture.runAsync(new Runnable() {
@Override
public void run() {
//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");
dockerProjectService.jenkinsBuild(dockerJenkinsReq);
}
});
}
return rtn;
... ...