mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-11-29 18:38:32 +08:00
fix webhook
This commit is contained in:
parent
3614feb48c
commit
5f5a1bdfa5
@ -55,6 +55,7 @@ import org.dromara.jpom.socket.AgentFileTailWatcher;
|
||||
import org.dromara.jpom.socket.ConsoleCommandOp;
|
||||
import org.dromara.jpom.util.CommandUtil;
|
||||
import org.dromara.jpom.util.JvmUtil;
|
||||
import org.dromara.jpom.webhook.DefaultWebhookPluginImpl;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.io.File;
|
||||
@ -354,6 +355,7 @@ public abstract class AbstractProjectCommander implements ProjectCommander {
|
||||
map.put("projectId", nodeProjectInfoModel.getId());
|
||||
map.put("projectName", nodeProjectInfoModel.getName());
|
||||
map.put("type", type);
|
||||
map.put("JPOM_WEBHOOK_EVENT", DefaultWebhookPluginImpl.WebhookEvent.PROJECT);
|
||||
|
||||
for (int i = 0; i < other.length; i += 2) {
|
||||
map.put(other[i].toString(), other[i + 1]);
|
||||
|
@ -69,6 +69,7 @@ import org.dromara.jpom.util.AntPathUtil;
|
||||
import org.dromara.jpom.util.CommandUtil;
|
||||
import org.dromara.jpom.util.FileUtils;
|
||||
import org.dromara.jpom.util.LogRecorder;
|
||||
import org.dromara.jpom.webhook.DefaultWebhookPluginImpl;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.io.File;
|
||||
@ -921,6 +922,7 @@ public class BuildExecuteManage implements Runnable {
|
||||
ThreadUtil.execute(() -> {
|
||||
try {
|
||||
IPlugin plugin = PluginFactory.getPlugin("webhook");
|
||||
map.put("JPOM_WEBHOOK_EVENT", DefaultWebhookPluginImpl.WebhookEvent.BUILD);
|
||||
plugin.execute(s, map);
|
||||
} catch (Exception e) {
|
||||
log.error("WebHooks 调用错误", e);
|
||||
|
@ -49,6 +49,7 @@ import org.dromara.jpom.service.monitor.MonitorService;
|
||||
import org.dromara.jpom.service.node.NodeService;
|
||||
import org.dromara.jpom.service.node.ProjectInfoCacheService;
|
||||
import org.dromara.jpom.service.user.UserService;
|
||||
import org.dromara.jpom.webhook.DefaultWebhookPluginImpl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -272,6 +273,7 @@ public class MonitorItem implements Task {
|
||||
}
|
||||
IPlugin plugin = PluginFactory.getPlugin("webhook");
|
||||
Map<String, Object> map = new HashMap<>(10);
|
||||
map.put("JPOM_WEBHOOK_EVENT", DefaultWebhookPluginImpl.WebhookEvent.MONITOR);
|
||||
map.put("monitorId", monitorModel.getId());
|
||||
map.put("monitorName", monitorModel.getName());
|
||||
map.put("nodeId", monitorNotifyLog.getNodeId());
|
||||
|
@ -55,6 +55,7 @@ import org.dromara.jpom.service.outgiving.OutGivingServer;
|
||||
import org.dromara.jpom.util.LogRecorder;
|
||||
import org.dromara.jpom.util.StrictSyncFinisher;
|
||||
import org.dromara.jpom.util.SyncFinisherUtil;
|
||||
import org.dromara.jpom.webhook.DefaultWebhookPluginImpl;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.io.File;
|
||||
@ -367,6 +368,7 @@ public class OutGivingRun {
|
||||
map.put("executeTime", SystemClock.now());
|
||||
try {
|
||||
IPlugin plugin = PluginFactory.getPlugin("webhook");
|
||||
map.put("JPOM_WEBHOOK_EVENT", DefaultWebhookPluginImpl.WebhookEvent.DISTRIBUTE);
|
||||
plugin.execute(webhook, map);
|
||||
} catch (Exception e) {
|
||||
log.error("WebHooks 调用错误", e);
|
||||
|
@ -43,12 +43,36 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
public class DefaultWebhookPluginImpl implements IDefaultPlugin {
|
||||
|
||||
public enum WebhookEvent {
|
||||
/**
|
||||
* 构建
|
||||
*/
|
||||
BUILD,
|
||||
/**
|
||||
* 项目
|
||||
*/
|
||||
PROJECT,
|
||||
/**
|
||||
* 监控
|
||||
*/
|
||||
MONITOR,
|
||||
/**
|
||||
* 分发
|
||||
*/
|
||||
DISTRIBUTE,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object execute(Object main, Map<String, Object> parameter) {
|
||||
String webhook = StrUtil.toStringOrNull(main);
|
||||
if (StrUtil.isEmpty(webhook)) {
|
||||
return null;
|
||||
}
|
||||
Object jpomWebhookEvent = parameter.remove("JPOM_WEBHOOK_EVENT");
|
||||
if (jpomWebhookEvent instanceof WebhookEvent) {
|
||||
WebhookEvent webhookEvent = (WebhookEvent) jpomWebhookEvent;
|
||||
log.debug("webhook event: [{}]{}", webhookEvent, webhook);
|
||||
}
|
||||
try {
|
||||
HttpRequest httpRequest = HttpUtil.createGet(webhook, true);
|
||||
httpRequest.form(parameter);
|
||||
|
@ -1,4 +1,4 @@
|
||||
## 项目介绍(未开发完成请勿使用)
|
||||
## 项目介绍
|
||||
|
||||
本项目采用 [Vue3](https://cn.vuejs.org/guide/introduction.html#what-is-vue) + [Vite](https://vitejs.dev/) + [TypeScript](https://www.typescriptlang.org/) + [Antdv](https://antdv.com/docs/vue/getting-started-cn) + [Pinia](https://pinia.vuejs.org/)构建。
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jpom-vue3",
|
||||
"private": true,
|
||||
"version": "2.10.39",
|
||||
"version": "2.10.47",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite --mode dev",
|
||||
|
@ -48,19 +48,10 @@ export default defineConfig(({ mode }: ConfigEnv) => {
|
||||
alias: {
|
||||
'@/': `${path.resolve(__dirname, 'src')}/`
|
||||
},
|
||||
// dedupe: ['vue'],
|
||||
// preserveSymlinks: false,
|
||||
|
||||
// 忽略后缀名的配置选项
|
||||
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
|
||||
},
|
||||
// rollupOptions: {
|
||||
// external: ['vue'],
|
||||
// output: {
|
||||
// globals: {
|
||||
// vue: 'Vue'
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
build: {
|
||||
sourcemap: mode !== 'production', // 非生产环境都生成sourcemap
|
||||
outDir: '../modules/server/src/main/resources/dist'
|
||||
|
Loading…
Reference in New Issue
Block a user