mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-12-02 03:48:05 +08:00
fix 文件发布-节点发布文件名使用真实名称
This commit is contained in:
parent
4cea3a2f71
commit
6a21b83e87
@ -11,6 +11,8 @@
|
||||
1. 【server】优化 仓库账号、 SSH 证书密码支持选择环境变量
|
||||
2. 【all】升级 commons-compress、fastjson、hutool 版本
|
||||
3. 【server】优化 maven 依赖冲突
|
||||
4. 【server】优化 文件发布-节点发布文件名使用真实名称(感谢@勤思·)
|
||||
5. 【server】优化 文件发布-ssh发布新增变量:FILE_NAME、FILE_EXT_NAME
|
||||
|
||||
------
|
||||
|
||||
|
4
PLANS.md
4
PLANS.md
@ -3,7 +3,7 @@
|
||||
## 2.10.x
|
||||
|
||||
1. **构建流水线**
|
||||
2. netty-agent
|
||||
2. **netty-agent**
|
||||
3. 凭证管理
|
||||
4. 升级 JDK 11 或者 17
|
||||
5. 端口监控、监控报警、机器监控、ssh 监控报警
|
||||
@ -23,7 +23,7 @@
|
||||
19. ~~docker 容器编辑重建(zx)~~
|
||||
20. 前端主题切换
|
||||
21. docker-compose sh
|
||||
22. 仓库密码、ssh 密码引用环境变量支持使用下拉框 sh
|
||||
22. ~~仓库密码、ssh 密码引用环境变量支持使用下拉框 sh~~
|
||||
23. 监控通知模块优化支持更多(飞书) zx
|
||||
24. SSH 修改文件权限 zx
|
||||
25. vue3 资产管理 zs
|
||||
|
@ -309,7 +309,20 @@ public class NodeForward {
|
||||
*/
|
||||
public static <T> JsonMessage<T> requestSharding(NodeModel nodeModel, NodeUrl nodeUrl, JSONObject jsonObject, File file, Function<JSONObject, JsonMessage<T>> doneCallback, BiConsumer<Long, Long> streamProgress) throws IOException {
|
||||
INodeInfo nodeInfo = parseNodeInfo(nodeModel);
|
||||
return requestSharding(nodeInfo, nodeModel.getWorkspaceId(), nodeUrl, jsonObject, file, doneCallback, streamProgress);
|
||||
return requestSharding(nodeInfo, nodeModel.getWorkspaceId(), nodeUrl, jsonObject, file, File::getName, doneCallback, streamProgress);
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通消息转发
|
||||
*
|
||||
* @param nodeModel 节点
|
||||
* @param nodeUrl 节点的url
|
||||
* @param jsonObject 数据
|
||||
* @return JSON
|
||||
*/
|
||||
public static <T> JsonMessage<T> requestSharding(NodeModel nodeModel, NodeUrl nodeUrl, JSONObject jsonObject, File file, String fileName, Function<JSONObject, JsonMessage<T>> doneCallback, BiConsumer<Long, Long> streamProgress) throws IOException {
|
||||
INodeInfo nodeInfo = parseNodeInfo(nodeModel);
|
||||
return requestSharding(nodeInfo, nodeModel.getWorkspaceId(), nodeUrl, jsonObject, file, file1 -> fileName, doneCallback, streamProgress);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -322,7 +335,7 @@ public class NodeForward {
|
||||
*/
|
||||
public static <T> JsonMessage<T> requestSharding(MachineNodeModel machineNodeModel, NodeUrl nodeUrl, JSONObject jsonObject, File file, Function<JSONObject, JsonMessage<T>> doneCallback, BiConsumer<Long, Long> streamProgress) throws IOException {
|
||||
INodeInfo nodeInfo = coverNodeInfo(machineNodeModel);
|
||||
return requestSharding(nodeInfo, StrUtil.EMPTY, nodeUrl, jsonObject, file, doneCallback, streamProgress);
|
||||
return requestSharding(nodeInfo, StrUtil.EMPTY, nodeUrl, jsonObject, file, File::getName, doneCallback, streamProgress);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -335,12 +348,12 @@ public class NodeForward {
|
||||
* @param jsonObject 数据
|
||||
* @return JSON
|
||||
*/
|
||||
private static <T> JsonMessage<T> requestSharding(INodeInfo nodeInfo, String workspaceId, NodeUrl nodeUrl, JSONObject jsonObject, File file, Function<JSONObject, JsonMessage<T>> doneCallback, BiConsumer<Long, Long> streamProgress) throws IOException {
|
||||
private static <T> JsonMessage<T> requestSharding(INodeInfo nodeInfo, String workspaceId, NodeUrl nodeUrl, JSONObject jsonObject, File file, Function<File, String> fileNameFn, Function<JSONObject, JsonMessage<T>> doneCallback, BiConsumer<Long, Long> streamProgress) throws IOException {
|
||||
IUrlItem urlItem = parseUrlItem(nodeInfo, workspaceId, nodeUrl, DataContentType.FORM_URLENCODED);
|
||||
ServerConfig serverConfig = SpringUtil.getBean(ServerConfig.class);
|
||||
ServerConfig.NodeConfig nodeConfig = serverConfig.getNode();
|
||||
long length = file.length();
|
||||
String fileName = file.getName();
|
||||
String fileName = fileNameFn.apply(file);
|
||||
Assert.state(length > 0, "空文件不能上传");
|
||||
String md5 = SecureUtil.md5(file);
|
||||
int fileSliceSize = nodeConfig.getUploadFileSliceSize();
|
||||
|
@ -184,7 +184,7 @@ public class FileReleaseTaskService extends BaseWorkspaceService<FileReleaseTask
|
||||
releaseTaskLogModel.setReleasePath(taskRoot.getReleasePath());
|
||||
this.insert(releaseTaskLogModel);
|
||||
}
|
||||
this.startTask(taskRoot.getId(), file, env);
|
||||
this.startTask(taskRoot.getId(), file, env, storageModel);
|
||||
return JsonMessage.success("创建成功");
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ public class FileReleaseTaskService extends BaseWorkspaceService<FileReleaseTask
|
||||
* @param taskId 任务id
|
||||
* @param storageSaveFile 文件
|
||||
*/
|
||||
private void startTask(String taskId, File storageSaveFile, Map<String, String> env) {
|
||||
private void startTask(String taskId, File storageSaveFile, Map<String, String> env, FileStorageModel storageModel) {
|
||||
FileReleaseTaskLogModel taskRoot = this.getByKey(taskId);
|
||||
Assert.notNull(taskRoot, "没有找到父级任务");
|
||||
//
|
||||
@ -207,6 +207,8 @@ public class FileReleaseTaskService extends BaseWorkspaceService<FileReleaseTask
|
||||
Optional.ofNullable(env).ifPresent(environmentMapBuilder::putStr);
|
||||
environmentMapBuilder.put("TASK_ID", taskRoot.getTaskId());
|
||||
environmentMapBuilder.put("FILE_ID", taskRoot.getFileId());
|
||||
environmentMapBuilder.put("FILE_NAME", storageModel.getName());
|
||||
environmentMapBuilder.put("FILE_EXT_NAME", storageModel.getExtName());
|
||||
//
|
||||
String syncFinisherId = "file-release:" + taskId;
|
||||
StrictSyncFinisher strictSyncFinisher = SyncFinisherUtil.create(syncFinisherId, logModels.size());
|
||||
@ -214,7 +216,8 @@ public class FileReleaseTaskService extends BaseWorkspaceService<FileReleaseTask
|
||||
if (taskType == 0) {
|
||||
crateTaskSshWork(logModels, strictSyncFinisher, taskRoot, environmentMapBuilder, storageSaveFile);
|
||||
} else if (taskType == 1) {
|
||||
crateTaskNodeWork(logModels, strictSyncFinisher, taskRoot, environmentMapBuilder, storageSaveFile);
|
||||
// 节点
|
||||
crateTaskNodeWork(logModels, strictSyncFinisher, taskRoot, environmentMapBuilder, storageSaveFile, storageModel);
|
||||
} else {
|
||||
throw new IllegalArgumentException("不支持的方式");
|
||||
}
|
||||
@ -274,7 +277,8 @@ public class FileReleaseTaskService extends BaseWorkspaceService<FileReleaseTask
|
||||
StrictSyncFinisher strictSyncFinisher,
|
||||
FileReleaseTaskLogModel taskRoot,
|
||||
EnvironmentMapBuilder environmentMapBuilder,
|
||||
File storageSaveFile) {
|
||||
File storageSaveFile,
|
||||
FileStorageModel storageModel) {
|
||||
String taskId = taskRoot.getId();
|
||||
for (FileReleaseTaskLogModel model : values) {
|
||||
model.setAfterScript(taskRoot.getAfterScript());
|
||||
@ -302,7 +306,9 @@ public class FileReleaseTaskService extends BaseWorkspaceService<FileReleaseTask
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("path", releasePath);
|
||||
Set<Integer> progressRangeList = ConcurrentHashMap.newKeySet((int) Math.floor((float) 100 / buildExtConfig.getLogReduceProgressRatio()));
|
||||
JsonMessage<String> jsonMessage = NodeForward.requestSharding(item, NodeUrl.Manage_File_Upload_Sharding2, data, storageSaveFile,
|
||||
String name = storageModel.getName();
|
||||
name = StrUtil.wrapIfMissing(name, StrUtil.EMPTY, StrUtil.DOT + storageModel.getExtName());
|
||||
JsonMessage<String> jsonMessage = NodeForward.requestSharding(item, NodeUrl.Manage_File_Upload_Sharding2, data, storageSaveFile, name,
|
||||
sliceData -> {
|
||||
sliceData.putAll(data);
|
||||
return NodeForward.request(item, NodeUrl.Manage_File_Sharding_Merge2, sliceData);
|
||||
@ -423,6 +429,7 @@ public class FileReleaseTaskService extends BaseWorkspaceService<FileReleaseTask
|
||||
logRecorder.system("{} start ftp upload", item.getName());
|
||||
|
||||
MySftp.ProgressMonitor sftpProgressMonitor = sshService.createProgressMonitor(logRecorder);
|
||||
// 不需要关闭资源,因为共用会话
|
||||
MySftp sftp = new MySftp(session, charset, timeout, sftpProgressMonitor);
|
||||
channelSftp = sftp.getClient();
|
||||
String releasePath = model.getReleasePath();
|
||||
|
@ -35,6 +35,7 @@ import org.dromara.jpom.model.BaseMachineModel;
|
||||
*
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
* @see MachineNodeModel
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName(value = "NODE_INFO", name = "节点信息")
|
||||
|
@ -18,6 +18,14 @@
|
||||
<a-input v-model="envVarListQuery['%description%']" placeholder="描述" @pressEnter="loadDataEnvVar" allowClear class="search-input-item" />
|
||||
<a-button type="primary" @click="loadDataEnvVar">搜索</a-button>
|
||||
<a-button type="primary" @click="addEnvVar">新增</a-button>
|
||||
<a-tooltip>
|
||||
<template slot="title">
|
||||
<div>环境变量是指配置在系统中的一些固定参数值,用于脚本执行时候快速引用。</div>
|
||||
<div>环境变量还可以用于仓库账号密码、ssh密码引用</div>
|
||||
<div>注意:环境变量存在作用域:当前工作空间或者全局,不能跨工作空间引用</div>
|
||||
</template>
|
||||
<a-icon type="question-circle" theme="filled" />
|
||||
</a-tooltip>
|
||||
</a-space>
|
||||
</template>
|
||||
<a-tooltip slot="value" slot-scope="text, item" placement="topLeft" :title="item.privacy === 1 ? '隐私字段' : text">
|
||||
|
Loading…
Reference in New Issue
Block a user