Search in sources :

Example 1 with BuildStatus

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;
}
Also used : UserModel(io.jpom.model.data.UserModel) JSONObject(com.alibaba.fastjson.JSONObject) BuildStatus(io.jpom.model.enums.BuildStatus) BuildInfoModel(io.jpom.model.data.BuildInfoModel)

Example 2 with BuildStatus

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;
}
Also used : BuildStatus(io.jpom.model.enums.BuildStatus)

Example 3 with BuildStatus

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, "取消成功");
}
Also used : BuildStatus(io.jpom.model.enums.BuildStatus) BuildInfoModel(io.jpom.model.data.BuildInfoModel) Feature(io.jpom.permission.Feature) MethodFeature(io.jpom.permission.MethodFeature) ClassFeature(io.jpom.permission.ClassFeature) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

BuildStatus (io.jpom.model.enums.BuildStatus)3 BuildInfoModel (io.jpom.model.data.BuildInfoModel)2 JSONObject (com.alibaba.fastjson.JSONObject)1 UserModel (io.jpom.model.data.UserModel)1 ClassFeature (io.jpom.permission.ClassFeature)1 Feature (io.jpom.permission.Feature)1 MethodFeature (io.jpom.permission.MethodFeature)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1