mirror of
https://github.com/quay/quay.git
synced 2026-10-23 09:49:06 +03:00
PROJQUAY-12196: fix(buildman): fire build_start notification on phase transition (#6443)
* PROJQUAY-12196: fix(buildman): fire build_start notification on phase transition
The BuildStartEvent was defined and configurable via the UI but never
triggered. Add send_notification("build_start") when the build phase
transitions to BUILDING.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* PROJQUAY-12196: test(notifications): add build_start webhook E2E test
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -491,6 +491,9 @@ class EphemeralBuilderManager(BuildStateInterface):
|
||||
build_job.build_uuid, phase, self._build_logs.PHASE, phase_metadata
|
||||
)
|
||||
|
||||
if phase == BUILD_PHASE.BUILDING:
|
||||
build_job.send_notification("build_start")
|
||||
|
||||
# Check if on_job_complete needs to be called
|
||||
if updated and phase in EphemeralBuilderManager.COMPLETED_PHASES:
|
||||
executor_name = job_data_json.get("executor_name")
|
||||
|
||||
@@ -890,4 +890,46 @@ test.describe('Repository Notifications', {tag: ['@repository']}, () => {
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'build_start notification delivered via webhook',
|
||||
{tag: ['@feature:BUILD_SUPPORT', '@PROJQUAY-12196']},
|
||||
async ({api}) => {
|
||||
test.setTimeout(300_000);
|
||||
const org = await api.organization('buildstartwh');
|
||||
const repo = await api.repository(org.name, 'buildstartrepo');
|
||||
|
||||
const receiver = new WebhookReceiver();
|
||||
await receiver.start();
|
||||
|
||||
try {
|
||||
await api.notification(
|
||||
org.name,
|
||||
repo.name,
|
||||
'build_start',
|
||||
'webhook',
|
||||
{url: receiver.getUrl()},
|
||||
'Build Start Webhook',
|
||||
);
|
||||
|
||||
const build = await api.build(
|
||||
org.name,
|
||||
repo.name,
|
||||
'FROM scratch\nLABEL build="build-start-test"\n',
|
||||
);
|
||||
|
||||
const webhook = await receiver.waitForWebhook(
|
||||
(req) =>
|
||||
req.body.build_id === build.buildId &&
|
||||
req.body.repository === `${org.name}/${repo.name}`,
|
||||
240000,
|
||||
);
|
||||
expect(webhook, 'build_start webhook not received').not.toBeNull();
|
||||
expect(webhook!.body.repository).toBe(`${org.name}/${repo.name}`);
|
||||
expect(webhook!.body.build_id).toBe(build.buildId);
|
||||
} finally {
|
||||
await receiver.stop();
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user