Search in sources :

Example 11 with BuildInfoModel

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);
    }
}
Also used : BuildHistoryLog(io.jpom.model.log.BuildHistoryLog) File(java.io.File) BuildInfoModel(io.jpom.model.data.BuildInfoModel) ClassFeature(io.jpom.permission.ClassFeature) Feature(io.jpom.permission.Feature) MethodFeature(io.jpom.permission.MethodFeature) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 12 with BuildInfoModel

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);
}
Also used : BuildInfoModel(io.jpom.model.data.BuildInfoModel) ClassFeature(io.jpom.permission.ClassFeature) Feature(io.jpom.permission.Feature) MethodFeature(io.jpom.permission.MethodFeature) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with BuildInfoModel

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);
    }
}
Also used : BuildHistoryLog(io.jpom.model.log.BuildHistoryLog) File(java.io.File) BuildInfoModel(io.jpom.model.data.BuildInfoModel) ClassFeature(io.jpom.permission.ClassFeature) Feature(io.jpom.permission.Feature) MethodFeature(io.jpom.permission.MethodFeature) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with BuildInfoModel

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);
}
Also used : BuildInfoModel(io.jpom.model.data.BuildInfoModel) ClassFeature(io.jpom.permission.ClassFeature) Feature(io.jpom.permission.Feature) MethodFeature(io.jpom.permission.MethodFeature) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 15 with BuildInfoModel

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

Aggregations

BuildInfoModel (io.jpom.model.data.BuildInfoModel)22 ClassFeature (io.jpom.permission.ClassFeature)12 Feature (io.jpom.permission.Feature)12 MethodFeature (io.jpom.permission.MethodFeature)12 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 File (java.io.File)7 UserModel (io.jpom.model.data.UserModel)5 BuildHistoryLog (io.jpom.model.log.BuildHistoryLog)5 JSONObject (com.alibaba.fastjson.JSONObject)4 JsonMessage (cn.jiangzeyin.common.JsonMessage)3 BuildStatus (io.jpom.model.enums.BuildStatus)3 RepositoryModel (io.jpom.model.data.RepositoryModel)2 Convert (cn.hutool.core.convert.Convert)1 RegexPool (cn.hutool.core.lang.RegexPool)1 Validator (cn.hutool.core.lang.Validator)1 ObjectUtil (cn.hutool.core.util.ObjectUtil)1 StrUtil (cn.hutool.core.util.StrUtil)1 Entity (cn.hutool.db.Entity)1 ServletUtil (cn.hutool.extra.servlet.ServletUtil)1 DefaultSystemLog (cn.jiangzeyin.common.DefaultSystemLog)1