use of io.jpom.model.data.BuildInfoModel in project Jpom by dromara.
the class BuildTriggerApiController method updateItem.
/**
* 接收参数,修改
*
* @param jsonObject 参数
* @return 错误消息
*/
private String updateItem(JSONObject jsonObject) {
String id = jsonObject.getString("id");
String branchName = jsonObject.getString("branchName");
String branchTagName = jsonObject.getString("branchTagName");
String script = jsonObject.getString("script");
String resultDirFile = jsonObject.getString("resultDirFile");
String webhook = jsonObject.getString("webhook");
//
BuildInfoModel item = new BuildInfoModel();
if (StrUtil.isNotEmpty(branchName)) {
item.setBranchName(branchName);
}
if (StrUtil.isNotEmpty(branchTagName)) {
item.setBranchTagName(branchTagName);
}
if (StrUtil.isNotEmpty(script)) {
item.setScript(script);
}
if (StrUtil.isNotEmpty(resultDirFile)) {
item.setResultDirFile(resultDirFile);
}
if (StrUtil.isNotEmpty(webhook)) {
if (!Validator.isMatchRegex(RegexPool.URL_HTTP, webhook)) {
return "WebHooks 地址不合法";
}
item.setWebhook(webhook);
}
if (ObjectUtil.isNotEmpty(item)) {
item.setId(id);
buildInfoService.update(item);
}
return null;
}
use of io.jpom.model.data.BuildInfoModel in project Jpom by dromara.
the class DbBuildHistoryLogService method deleteLogAndFile.
/**
* 清理文件并删除记录
*
* @param buildHistoryLog 构建记录
* @return json
*/
public JsonMessage<String> deleteLogAndFile(BuildHistoryLog buildHistoryLog) {
if (buildHistoryLog == null) {
return new JsonMessage<>(405, "没有对应构建记录");
}
BuildInfoModel item = buildService.getByKey(buildHistoryLog.getBuildDataId());
if (item != null) {
File logFile = BuildUtil.getLogFile(item.getId(), buildHistoryLog.getBuildNumberId());
if (logFile != null) {
File dataFile = logFile.getParentFile();
if (dataFile.exists()) {
boolean s = FileUtil.del(dataFile);
if (!s) {
return new JsonMessage<>(500, "清理文件失败");
}
}
}
}
int count = this.delByKey(buildHistoryLog.getId());
return new JsonMessage<>(200, "删除成功", count + "");
}
Aggregations