Search in sources :

Example 21 with BuildInfoModel

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

Example 22 with BuildInfoModel

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 + "");
}
Also used : JsonMessage(cn.jiangzeyin.common.JsonMessage) File(java.io.File) 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