Skip to content

Add retries_count to job events webhook payload

Reuben Pereira requested to merge rp/add-retries-count-to-job-webhook into master

What does this MR do and why?

Describe in detail what your merge request does and why.

Currently, the job event webhook contains no indication if a job is running for the first time or is being retried for the nth time.

This MR adds retries_count to the job events payload.

When retries_count > 0, it means that this build is a retry. If retries_count is 2, this build is the 2nd retry of a job.

build.retries_count generates the following SQL query: https://console.postgres.ai/gitlab/gitlab-production-ci/sessions/12918/commands/45384.

This change is behind a feature flag called job_webhook_retries_count.

Issue: #382045 (closed)

This change will help achieve gitlab-com/gl-infra/delivery#2466 (closed).

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Enable the job_webhook_retries_count feature flag by running the following in a Rails console: Feature.enable(:job_webhook_retries_count).
  2. Allow webhook and service requests to local network.
  3. In your browser open https://test1.requestcatcher.com/.
  4. In a project, open the webhooks page (project settings > webhooks), and enter the following URL https://test1.requestcatcher.com/.
  5. Enter a random string as secret token.
  6. Check job events, and uncheck everything else. You can keep SSL verification enabled.
  7. Now start a CI pipeline in the same project.
  8. Check the page opened to https://test1.requestcatcher.com/ and see if the payload contains retries_count.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Reuben Pereira

Merge request reports