use of io.jpom.model.data.BuildInfoModel in project Jpom by dromara.
the class BuildInfoHistoryController method downloadLog.
@RequestMapping(value = "/build/history/download_log.html", method = RequestMethod.GET)
@ResponseBody
@Feature(method = MethodFeature.DOWNLOAD)
public void downloadLog(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "没有数据") String logId) throws IOException {
BuildHistoryLog buildHistoryLog = dbBuildHistoryLogService.getByKey(logId);
Objects.requireNonNull(buildHistoryLog);
BuildInfoModel item = buildInfoService.getByKey(buildHistoryLog.getBuildDataId());
Objects.requireNonNull(item);
File logFile = BuildUtil.getLogFile(item.getId(), buildHistoryLog.getBuildNumberId());
if (!FileUtil.exist(logFile)) {
return;
}
if (logFile.isFile()) {
ServletUtil.write(getResponse(), logFile);
}
}
use of io.jpom.model.data.BuildInfoModel in project Jpom by dromara.
the class BuildInfoTriggerController method getTriggerUrl.
/**
* get a trigger url
*
* @param id id
* @return json
*/
@RequestMapping(value = "/build/trigger/url", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.EDIT)
public String getTriggerUrl(String id) {
BuildInfoModel item = buildInfoService.getByKey(id);
if (StrUtil.isEmpty(item.getTriggerToken())) {
item.setTriggerToken(this.createTriggerUrl());
buildInfoService.update(item);
}
Map<String, String> map = this.getBuildToken(item);
return JsonMessage.getString(200, "ok", map);
}
use of io.jpom.model.data.BuildInfoModel in project Jpom by dromara.
the class BuildInfoHistoryController method downloadFile.
/**
* 下载构建物
*
* @param logId 日志id
*/
@RequestMapping(value = "/build/history/download_file.html", method = RequestMethod.GET)
@Feature(method = MethodFeature.DOWNLOAD)
public void downloadFile(@ValidatorConfig(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "没有数据")) String logId) {
BuildHistoryLog buildHistoryLog = dbBuildHistoryLogService.getByKey(logId);
if (buildHistoryLog == null) {
return;
}
BuildInfoModel item = buildInfoService.getByKey(buildHistoryLog.getBuildDataId());
if (item == null) {
return;
}
File logFile = BuildUtil.getHistoryPackageFile(item.getId(), buildHistoryLog.getBuildNumberId(), buildHistoryLog.getResultDirFile());
if (!FileUtil.exist(logFile)) {
return;
}
if (logFile.isFile()) {
ServletUtil.write(getResponse(), logFile);
} else {
File zipFile = BuildUtil.isDirPackage(logFile);
assert zipFile != null;
ServletUtil.write(getResponse(), zipFile);
}
}
use of io.jpom.model.data.BuildInfoModel in project Jpom by dromara.
the class BuildInfoTriggerController method triggerRest.
/**
* reset new trigger url
*
* @param id id
* @return json
*/
@RequestMapping(value = "/build/trigger/rest", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.EDIT)
public String triggerRest(String id) {
BuildInfoModel item = buildInfoService.getByKey(id, getRequest());
// new trigger url
item.setTriggerToken(this.createTriggerUrl());
buildInfoService.update(item);
Map<String, String> map = this.getBuildToken(item);
return JsonMessage.getString(200, "重置成功", map);
}
use of io.jpom.model.data.BuildInfoModel in project Jpom by dromara.
the class BuildExecuteService method runTask.
/**
* 创建构建
*
* @param taskData 任务
*/
private void runTask(TaskData taskData) {
BuildInfoModel buildInfoModel = taskData.buildInfoModel;
boolean containsKey = BUILD_MANAGE_MAP.containsKey(buildInfoModel.getId());
Assert.state(!containsKey, "当前构建还在进行中");
//
BuildExtraModule buildExtraModule = StringUtil.jsonConvert(buildInfoModel.getExtraData(), BuildExtraModule.class);
Assert.notNull(buildExtraModule, "构建信息缺失");
String logId = this.insertLog(buildExtraModule, taskData);
//
BuildInfoManage.BuildInfoManageBuilder builder = BuildInfoManage.builder().taskData(taskData).logId(logId).buildExtraModule(buildExtraModule).dbBuildHistoryLogService(dbBuildHistoryLogService).buildExecuteService(this);
BuildInfoManage build = builder.build();
// BuildInfoManage manage = new BuildInfoManage(taskData);
BUILD_MANAGE_MAP.put(buildInfoModel.getId(), build);
//
ThreadUtil.execute(build);
}
Aggregations