增加构建通知
This commit is contained in:
parent
b9d5fbe360
commit
cbe701a5af
@ -648,6 +648,10 @@ public class JenkinsBuildServiceImpl extends BaseServiceImpl<JenkinsBuild, Jenki
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (org.springframework.orm.ObjectOptimisticLockingFailureException e) {
|
||||||
|
// 乐观锁冲突,说明记录已被其他线程更新,忽略即可
|
||||||
|
log.warn("构建通知记录乐观锁冲突,跳过处理: teamId={}, envId={}, buildId={}",
|
||||||
|
config.getTeamId(), config.getEnvironmentId(), build.getId());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("处理构建通知失败: teamId={}, envId={}, buildId={}",
|
log.error("处理构建通知失败: teamId={}, envId={}, buildId={}",
|
||||||
config.getTeamId(), config.getEnvironmentId(), build.getId(), e);
|
config.getTeamId(), config.getEnvironmentId(), build.getId(), e);
|
||||||
@ -937,14 +941,16 @@ public class JenkinsBuildServiceImpl extends BaseServiceImpl<JenkinsBuild, Jenki
|
|||||||
*/
|
*/
|
||||||
private String uploadFileToWechat(NotificationChannel channel, String filePath) {
|
private String uploadFileToWechat(NotificationChannel channel, String filePath) {
|
||||||
try {
|
try {
|
||||||
// 从 config 中获取 webhook URL
|
// 从 config 中获取 key
|
||||||
String webhookUrl = (String) channel.getConfig().get("webhookUrl");
|
if (channel.getConfig() == null) {
|
||||||
if (webhookUrl == null || !webhookUrl.contains("key=")) {
|
log.error("企业微信渠道配置为空: channelId={}", channel.getId());
|
||||||
log.error("无效的企业微信 webhook URL: {}", webhookUrl);
|
return null;
|
||||||
|
}
|
||||||
|
String key = (String) channel.getConfig().get("key");
|
||||||
|
if (key == null || key.isEmpty()) {
|
||||||
|
log.error("企业微信渠道 key 为空: channelId={}", channel.getId());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String key = webhookUrl.substring(webhookUrl.indexOf("key=") + 4);
|
|
||||||
|
|
||||||
// 企业微信文件上传接口
|
// 企业微信文件上传接口
|
||||||
String uploadUrl = "https://qyapi.weixin.qq.com/cgi-bin/webhook/upload_media?key=" + key + "&type=file";
|
String uploadUrl = "https://qyapi.weixin.qq.com/cgi-bin/webhook/upload_media?key=" + key + "&type=file";
|
||||||
@ -1000,7 +1006,8 @@ public class JenkinsBuildServiceImpl extends BaseServiceImpl<JenkinsBuild, Jenki
|
|||||||
*/
|
*/
|
||||||
private void sendWechatFileMessage(NotificationChannel channel, String mediaId) {
|
private void sendWechatFileMessage(NotificationChannel channel, String mediaId) {
|
||||||
try {
|
try {
|
||||||
String webhookUrl = (String) channel.getConfig().get("webhookUrl");
|
String key = (String) channel.getConfig().get("key");
|
||||||
|
String webhookUrl = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=" + key;
|
||||||
|
|
||||||
// 构建文件消息
|
// 构建文件消息
|
||||||
Map<String, Object> message = new HashMap<>();
|
Map<String, Object> message = new HashMap<>();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user