fix: 同步 Jenkins 完成状态

This commit is contained in:
湛兮
2026-06-12 14:43:46 +08:00
parent 345fa67f3a
commit 1b645dd9c8
4 changed files with 480 additions and 57 deletions
@@ -301,6 +301,42 @@ describe('DeployExecutionService', () => {
);
});
it('recovers a completed Jenkins result from the console log when build status has no result yet', async () => {
const { audit, repository, service } = createService({
jenkinsHealth: { status: 'ok' },
notificationStatus: 'sent',
queueId: 'queue_log_success',
queueBuildNumber: 22,
logText: [
'deploy ok',
'[Pipeline] End of Pipeline',
'Finished: SUCCESS',
].join('\n'),
});
const run = await service.execute(
await createRun(repository, 'run_log_success_001'),
project,
);
const result = await service.syncJenkinsRun(run, project);
expect(result.status).toBe('success');
expect(result.jenkinsBuildNumber).toBe(22);
expect(step(result, 'jenkins-build')?.status).toBe('success');
expect(step(result, 'health-check')?.status).toBe('success');
expect(step(result, 'notify-wecom')?.status).toBe('success');
expect(step(result, 'finish-release')?.status).toBe('success');
expect(audit.record).toHaveBeenCalledWith(
expect.objectContaining({
action: 'JENKINS_BUILD_RESULT_RECOVERED_FROM_LOG',
after: expect.objectContaining({
buildNumber: 22,
result: 'SUCCESS',
}),
}),
);
});
it('links a Jenkins build by queue id when the queue item has expired', async () => {
const { audit, jenkins, repository, service } = createService({
jenkinsHealth: { status: 'ok' },