#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,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('projects', function (Blueprint $table) {
$table->string('jenkins_job_name', 255)->nullable()->comment('Jenkins Job 名称');
$table->boolean('jenkins_notify_enabled')->default(false)->comment('是否启用 Jenkins 通知');
$table->integer('jenkins_last_notified_build')->nullable()->comment('最后通知的构建号');
});
}
public function down(): void
{
Schema::table('projects', function (Blueprint $table) {
$table->dropColumn(['jenkins_job_name', 'jenkins_notify_enabled', 'jenkins_last_notified_build']);
});
}
};

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('jenkins_deployments', function (Blueprint $table) {
$table->id();
$table->foreignId('project_id')->nullable()->constrained()->onDelete('cascade');
$table->integer('build_number');
$table->string('job_name', 255);
$table->string('status', 20)->comment('SUCCESS, FAILURE, ABORTED, UNSTABLE');
$table->string('branch', 255)->nullable();
$table->string('commit_sha', 64)->nullable();
$table->string('triggered_by', 100)->nullable();
$table->integer('duration')->nullable()->comment('构建耗时(毫秒)');
$table->string('build_url', 500)->nullable();
$table->json('raw_data')->nullable();
$table->boolean('notified')->default(false);
$table->timestamps();
$table->unique(['job_name', 'build_number']);
$table->index(['project_id', 'created_at']);
});
}
public function down(): void
{
Schema::dropIfExists('jenkins_deployments');
}
};

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('scheduled_tasks', function (Blueprint $table) {
$table->id();
$table->string('name')->unique()->comment('任务唯一标识符');
$table->string('command')->comment('任务命令');
$table->string('description')->nullable()->comment('任务描述');
$table->string('frequency')->comment('执行频率描述');
$table->string('cron')->comment('Cron 表达式');
$table->boolean('enabled')->default(false)->comment('是否启用');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('scheduled_tasks');
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('jenkins_deployments', function (Blueprint $table) {
$table->json('build_params')->nullable()->after('raw_data')->comment('构建参数');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('jenkins_deployments', function (Blueprint $table) {
$table->dropColumn('build_params');
});
}
};