Skip to content

Add project attributes and source_project attributes to build hooks

Patrick Talbert requested to merge ptalbert/gitlab-org:build_event into master

What does this MR do and why?

  • Provide the standard 'projects' hook attributes for build events.
  • À la !86994 (merged), add source_pipeline attributes for downstream build events.

Signed-off-by: Patrick Talbert ptalbert@redhat.com

Screenshots or screen recordings

Not a screenshot but here is the output of a 'test' webhook event from the GDK running on this branch. Note it has two additional keys, project and source_pipeline:

{
  "object_kind": "build",
  "ref": "master",
  "tag": false,
  "before_sha": "0000000000000000000000000000000000000000",
  "sha": "de4d7f931e162f0b288779e39cfc85c916a53eac",
  "retries_count": 0,
  "build_id": 203,
  "build_name": "slack",
  "build_stage": "notify",
  "build_status": "success",
  "build_created_at": "2023-08-02T19:49:08.786Z",
  "build_started_at": null,
  "build_finished_at": null,
  "build_duration": null,
  "build_queued_duration": null,
  "build_allow_failure": false,
  "build_failure_reason": "unknown_failure",
  "pipeline_id": 12,
  "runner": {
    "id": 15,
    "description": "My runner15",
    "runner_type": "instance_type",
    "active": true,
    "is_shared": true,
    "tags": []
  },
  "project_id": 1,
  "project_name": "Toolbox / Gitlab Smoke Tests",
  "user": {
    "id": 1,
    "name": "Administrator",
    "username": "root",
    "avatar_url": "https://secure.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
    "email": "[REDACTED]"
  },
  "commit": {
    "id": 12,
    "name": null,
    "sha": "de4d7f931e162f0b288779e39cfc85c916a53eac",
    "message": "Fix include error",
    "author_name": "Rocky Mongare",
    "author_email": "rmongare@gitlab.com",
    "author_url": "mailto:rmongare@gitlab.com",
    "status": "success",
    "duration": null,
    "started_at": null,
    "finished_at": "2023-08-02T19:49:08.880Z"
  },
  "repository": {
    "name": "Gitlab Smoke Tests",
    "url": "ssh://git@127.0.0.1:2222/toolbox/gitlab-smoke-tests.git",
    "description": "Molestias quia vel perferendis fugiat.",
    "homepage": "https://3000-ptalbert-gitlaborg-cikgeeffbpi.ws-eu102.gitpod.io/toolbox/gitlab-smoke-tests",
    "git_http_url": "https://3000-ptalbert-gitlaborg-cikgeeffbpi.ws-eu102.gitpod.io/toolbox/gitlab-smoke-tests.git",
    "git_ssh_url": "ssh://git@127.0.0.1:2222/toolbox/gitlab-smoke-tests.git",
    "visibility_level": 0
  },
  "project": {
    "id": 1,
    "name": "Gitlab Smoke Tests",
    "description": "Molestias quia vel perferendis fugiat.",
    "web_url": "https://3000-ptalbert-gitlaborg-cikgeeffbpi.ws-eu102.gitpod.io/toolbox/gitlab-smoke-tests",
    "avatar_url": null,
    "git_ssh_url": "ssh://git@127.0.0.1:2222/toolbox/gitlab-smoke-tests.git",
    "git_http_url": "https://3000-ptalbert-gitlaborg-cikgeeffbpi.ws-eu102.gitpod.io/toolbox/gitlab-smoke-tests.git",
    "namespace": "Toolbox",
    "visibility_level": 0,
    "path_with_namespace": "toolbox/gitlab-smoke-tests",
    "default_branch": "main",
    "ci_config_path": null
  },
  "environment": null,
  "source_pipeline": {
    "project": {
      "id": 8,
      "web_url": "https://3000-ptalbert-gitlaborg-cikgeeffbpi.ws-eu102.gitpod.io/twitter/Typeahead.Js",
      "path_with_namespace": "twitter/Typeahead.Js"
    },
    "job_id": 36,
    "pipeline_id": 3
  }
}

How to set up and validate locally

N/A

MR acceptance checklist

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

Merge request reports