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 in build_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 *_iso fields.

The name follows status_changed_at on deployment webhooks.

How the value is set:

  • Gitlab::DataBuilder::Build reads the column each status already sets:

    Status Column
    created created_at
    pending queued_at
    running started_at
    success, failed, canceled, skipped finished_at
    Any other status updated_at

    updated_at changes 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 without finished_at. Otherwise both fields are null, so they never carry a time later than the status change.

  • Ci::ExecuteBuildHooksWorker looks up the column for the status pinned when the hook was enqueued. A pending event processed after the job starts still carries queued_at.

  • Bulk created events from Ci::ExecutePipelineBuildHooksWorker use the job's created_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

Screenshots or screen recordings

Not applicable. This is a backend change with no UI.

How to set up and validate locally

  1. In a project, add a webhook with Job events enabled. A request bin such as https://webhook.site works as the URL.
  2. Run a pipeline in that project.
  3. In the received job event payloads, check that build_status_changed_at and build_status_changed_at_iso are present and match the time of each status change.
  4. 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.

Edited by Cody West

Merge request reports

Loading
Loading