#feature: add Jenkins deploy monitor & log clean task

This commit is contained in:
2026-01-19 11:46:38 +08:00
parent 381d5e6e49
commit da3b05b7c0
22 changed files with 968 additions and 80 deletions

View File

@@ -0,0 +1,41 @@
<?php
namespace App\Console\Commands;
use App\Services\JenkinsMonitorService;
use Illuminate\Console\Command;
class JenkinsMonitorCommand extends Command
{
protected $signature = 'jenkins:monitor';
protected $description = '轮询 Jenkins 检查新构建并发送钉钉通知';
public function handle(JenkinsMonitorService $service): void
{
$this->info('开始检查 Jenkins 构建...');
$results = $service->checkAllProjects();
if (isset($results['skipped'])) {
$this->warn('跳过检查: ' . ($results['reason'] ?? 'unknown'));
return;
}
foreach ($results as $slug => $result) {
if (isset($result['skipped'])) {
$this->line(sprintf('[%s] 跳过: %s', $slug, $result['reason'] ?? 'unknown'));
continue;
}
$newBuilds = $result['new_builds'] ?? [];
if (empty($newBuilds)) {
$this->line(sprintf('[%s] 无新构建', $slug));
} else {
$this->info(sprintf('[%s] 发现 %d 个新构建: #%s', $slug, count($newBuilds), implode(', #', $newBuilds)));
}
}
$this->info('检查完成');
}
}