use of io.jpom.model.data.BuildInfoModel in project Jpom by dromara.
the class BuildInfoService method checkReleaseMethod.
/**
* 判断是否存在 发布关联
*
* @param dataId 数据ID
* @param request 请求对象
* @param releaseMethod 发布方法
* @return true 关联
*/
public boolean checkReleaseMethod(String dataId, HttpServletRequest request, BuildReleaseMethod releaseMethod) {
BuildInfoModel buildInfoModel = new BuildInfoModel();
String workspaceId = this.getCheckUserWorkspace(request);
buildInfoModel.setWorkspaceId(workspaceId);
buildInfoModel.setReleaseMethodDataId(dataId);
buildInfoModel.setReleaseMethod(releaseMethod.getCode());
return super.exists(buildInfoModel);
}
use of io.jpom.model.data.BuildInfoModel in project Jpom by dromara.
the class BuildInfoService method updateStatus.
/**
* 更新状态
*
* @param id ID
* @param buildStatus to Status
*/
public void updateStatus(String id, BuildStatus buildStatus) {
BuildInfoModel buildInfoModel = new BuildInfoModel();
buildInfoModel.setId(id);
buildInfoModel.setStatus(buildStatus.getCode());
this.update(buildInfoModel);
}
use of io.jpom.model.data.BuildInfoModel in project Jpom by dromara.
the class BuildTriggerApiController method getStatusData.
private JSONObject getStatusData(String id, String token) {
JSONObject jsonObject = new JSONObject();
BuildInfoModel item = buildInfoService.getByKey(id);
if (item == null) {
jsonObject.put("msg", "没有对应数据");
return jsonObject;
}
UserModel userModel = BuildTriggerApiController.this.getByUrlToken(token);
if (userModel == null) {
jsonObject.put("msg", "对应的用户不存在,触发器已失效");
return jsonObject;
}
//
if (!StrUtil.equals(token, item.getTriggerToken())) {
jsonObject.put("msg", "触发token错误,或者已经失效");
return jsonObject;
}
// 更新字段
Integer status = item.getStatus();
BuildStatus buildStatus = BaseEnum.getEnum(BuildStatus.class, status);
if (buildStatus == null) {
jsonObject.put("msg", "status code error");
} else {
jsonObject.put("msg", buildStatus.getDesc());
jsonObject.put("statusCode", buildStatus.getCode());
jsonObject.put("status", buildStatus.name());
}
jsonObject.put("buildNumberId", item.getBuildId());
return jsonObject;
}
use of io.jpom.model.data.BuildInfoModel in project Jpom by dromara.
the class BuildTriggerApiController method triggerBatch.
/**
* 构建触发器
* <p>
* 参数 <code>[
* {
* "id":"1",
* "token":"a",
* "delay":"0"
* }
* ]</code>
* <p>
* 响应 <code>[
* {
* "id":"1",
* "token":"a",
* "delay":"0",
* "msg":"开始构建",
* "data":1
* }
* ]</code>
*
* @return json
*/
@PostMapping(value = ServerOpenApi.BUILD_TRIGGER_BUILD_BATCH, produces = MediaType.APPLICATION_JSON_VALUE)
public String triggerBatch() {
try {
String body = ServletUtil.getBody(getRequest());
JSONArray jsonArray = JSONArray.parseArray(body);
List<Object> collect = jsonArray.stream().peek(o -> {
JSONObject jsonObject = (JSONObject) o;
String id = jsonObject.getString("id");
String token = jsonObject.getString("token");
Integer delay = jsonObject.getInteger("delay");
String buildRemark = jsonObject.getString("buildRemark");
BuildInfoModel item = buildInfoService.getByKey(id);
if (item == null) {
jsonObject.put("msg", "没有对应数据");
return;
}
UserModel userModel = BuildTriggerApiController.this.getByUrlToken(token);
if (userModel == null) {
jsonObject.put("msg", "对应的用户不存在,触发器已失效");
return;
}
//
if (!StrUtil.equals(token, item.getTriggerToken())) {
jsonObject.put("msg", "触发token错误,或者已经失效");
return;
}
// 更新字段
String updateItemErrorMsg = this.updateItem(jsonObject);
if (updateItemErrorMsg != null) {
jsonObject.put("msg", updateItemErrorMsg);
return;
}
BaseServerController.resetInfo(userModel);
//
JsonMessage<Integer> start = buildExecuteService.start(id, userModel, delay, 1, buildRemark);
jsonObject.put("msg", start.getMsg());
jsonObject.put("buildId", start.getData());
}).collect(Collectors.toList());
return JsonMessage.getString(200, "触发成功", collect);
} catch (Exception e) {
DefaultSystemLog.getLog().error("构建触发批量触发异常", e);
return JsonMessage.getString(500, "触发异常", e.getMessage());
}
}
use of io.jpom.model.data.BuildInfoModel in project Jpom by dromara.
the class BuildInfoController method getBuildList.
/**
* load build list with params
*
* @return json
*/
@RequestMapping(value = "/build/list", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.LIST)
public String getBuildList() {
// load list with page
PageResultDto<BuildInfoModel> page = buildInfoService.listPage(getRequest());
page.each(buildInfoModel -> {
// 获取源码目录是否存在
File source = BuildUtil.getSourceById(buildInfoModel.getId());
buildInfoModel.setSourceDirExist(FileUtil.exist(source));
});
return JsonMessage.getString(200, "", page);
}
Aggregations