Add status change timestamp to job webhook payloads
What does this MR do and why?
Job webhook payloads have no timestamp for the event itself. Consumers such as CI visibility tools fall back to the time a webhook arrives, which is wrong when delivery is delayed or out of order.
This MR adds two fields to job webhook payloads:
build_status_changed_at: the time of the status change inbuild_status. For finished jobs, this is the time the runner reported completion.build_status_changed_at_iso: the same value in ISO 8601, matching the existing*_isofields.
The name follows status_changed_at on deployment webhooks.
How the value is set:
-
Gitlab::DataBuilder::Buildreads the column each status already sets:Status Column createdcreated_atpendingqueued_atrunningstarted_atsuccess,failed,canceled,skippedfinished_atAny other status updated_atupdated_atchanges with every save, so it is used only while the status is the job's current status. This also covers a status whose column is not set, such as a skipped job withoutfinished_at. Otherwise both fields arenull, so they never carry a time later than the status change. -
Ci::ExecuteBuildHooksWorkerlooks up the column for the status pinned when the hook was enqueued. Apendingevent processed after the job starts still carriesqueued_at. -
Bulk
createdevents fromCi::ExecutePipelineBuildHooksWorkeruse the job'screated_at.
No time is added to the Sidekiq job arguments, so deduplication of Ci::ExecuteBuildHooksWorker is unchanged. Webhook test events and jobs enqueued before a deploy also get the real event time.
This MR has no feature flag. It only adds two fields to the payload and does not change existing fields.
References
- #327441
- Deployment webhook precedent: !60518 (merged)
Screenshots or screen recordings
Not applicable. This is a backend change with no UI.
How to set up and validate locally
- In a project, add a webhook with Job events enabled. A request bin such as https://webhook.site works as the URL.
- Run a pipeline in that project.
- In the received job event payloads, check that
build_status_changed_atandbuild_status_changed_at_isoare present and match the time of each status change. - On the webhook's settings page, select Test > Job events and check that the test payload includes both fields.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.