use of io.jpom.model.enums.BuildStatus 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.enums.BuildStatus in project Jpom by dromara.
the class BuildExecuteService method checkStatus.
/**
* check status
*
* @param status 状态码
* @return 错误消息
*/
public String checkStatus(Integer status) {
if (status == null) {
return null;
}
BuildStatus nowStatus = BaseEnum.getEnum(BuildStatus.class, status);
Objects.requireNonNull(nowStatus);
if (BuildStatus.Ing == nowStatus || BuildStatus.PubIng == nowStatus) {
return "当前还在:" + nowStatus.getDesc();
}
return null;
}
use of io.jpom.model.enums.BuildStatus in project Jpom by dromara.
the class BuildInfoManageController method cancel.
/**
* 取消构建
*
* @param id id
* @return json
*/
@RequestMapping(value = "/build/manage/cancel", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.EXECUTE)
public String cancel(@ValidatorConfig(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "没有数据")) String id) {
BuildInfoModel item = buildInfoService.getByKey(id, getRequest());
Objects.requireNonNull(item, "没有对应数据");
BuildStatus nowStatus = BaseEnum.getEnum(BuildStatus.class, item.getStatus());
Objects.requireNonNull(nowStatus);
if (BuildStatus.Ing != nowStatus && BuildStatus.PubIng != nowStatus) {
return JsonMessage.getString(501, "当前状态不在进行中");
}
boolean status = buildExecuteService.cancelTask(item.getId());
if (!status) {
/*BuildInfoModel buildInfoModel = new BuildInfoModel();
buildInfoModel.setId(id);
buildInfoModel.setStatus(BuildStatus.Cancel.getCode());*/
buildInfoService.updateStatus(id, BuildStatus.Cancel);
}
return JsonMessage.getString(200, "取消成功");
}
Aggregations