Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit and update webhooks events #357

Closed
gmessner opened this issue May 16, 2019 · 3 comments
Closed

Audit and update webhooks events #357

gmessner opened this issue May 16, 2019 · 3 comments

Comments

@gmessner
Copy link
Collaborator

GitLab has changed and added fields to the webhook events in recent releases. We need to audit the current event classes and update to match the current GitLab Webhooks documentation.

Current know issues are:

Build Event has been renamed Job Event
The Pipeline Event has had fields added to it.

@gmessner
Copy link
Collaborator Author

Audit and updates have been completed and released in version 4.11.0

@gmessner
Copy link
Collaborator Author

@maguro
I decided to validate this with real information from an actual Job Hook event. Believe it or not, the documentation is completely wrong on GitLab. So I am reopening this to fix it correctly. I will also submit a bug to GitLab on this.

The actual event received, notice the object_kind and the use of the word build:

POST / HTTP/1.1
Host: gitlab4j.requestcatcher.com
Connection: close
Connection: close
Content-Length: 1187
Content-Type: application/json
X-Gitlab-Event: Job Hook
{
  "object_kind": "build",
  "ref": "master",
  "tag": false,
  "before_sha": "8a49a94f1a7cd64985074cb11b1a42a7ab2d9b46",
  "sha": "a890bee24574603c522c756b9346649fbec4c812",
  "build_id": 214655258,
  "build_name": "build1",
  "build_stage": "build",
  "build_status": "running",
  "build_started_at": "2019-05-17 18:09:21 UTC",
  "build_finished_at": null,
  "build_duration": 0.058808172,
  "build_allow_failure": false,
  "build_failure_reason": "unknown_failure",
  "project_id": 3115610,
  "project_name": "Greg Messner / test-project",
  "user": {
    "id": 20493,
    "name": "Greg Messner",
    "email": "greg@messners.com"
  },
  "commit": {
    "id": 61897408,
    "sha": "a890bee24574603c522c756b9346649fbec4c812",
    "message": "Add new file",
    "author_name": "Greg Messner",
    "author_email": "greg@messners.com",
    "author_url": "https://gitlab.com/gmessner",
    "status": "pending",
    "duration": null,
    "started_at": null,
    "finished_at": null
  },
  "repository": {
    "name": "test-project",
    "url": "git@gitlab.com:gmessner/test-project.git",
    "description": "This is a test project to be used for testing the GitLab4J-API",
    "homepage": "https://gitlab.com/gmessner/test-project",
    "git_http_url": "https://gitlab.com/gmessner/test-project.git",
    "git_ssh_url": "git@gitlab.com:gmessner/test-project.git",
    "visibility_level": 20
  }
}

The event from the documentation at https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#job-events . Notice the object_kind and the use of the word job:

Content-Type: application/json
X-Gitlab-Event: Job Hook
{
  "object_kind": "job",
  "ref": "gitlab-script-trigger",
  "tag": false,
  "before_sha": "2293ada6b400935a1378653304eaf6221e0fdb8f",
  "sha": "2293ada6b400935a1378653304eaf6221e0fdb8f",
  "job_id": 1977,
  "job_name": "test",
  "job_stage": "test",
  "job_status": "created",
  "job_started_at": null,
  "job_finished_at": null,
  "job_duration": null,
  "job_allow_failure": false,
  "job_failure_reason": "script_failure",
  "project_id": 380,
  "project_name": "gitlab-org/gitlab-test",
  "user": {
    "id": 3,
    "name": "User",
    "email": "user@gitlab.com"
  },
  "commit": {
    "id": 2366,
    "sha": "2293ada6b400935a1378653304eaf6221e0fdb8f",
    "message": "test\n",
    "author_name": "User",
    "author_email": "user@gitlab.com",
    "status": "created",
    "duration": null,
    "started_at": null,
    "finished_at": null
  },
  "repository": {
    "name": "gitlab_test",
    "description": "Atque in sunt eos similique dolores voluptatem.",
    "homepage": "http://192.168.64.1:3005/gitlab-org/gitlab-test",
    "git_ssh_url": "git@192.168.64.1:gitlab-org/gitlab-test.git",
    "git_http_url": "http://192.168.64.1:3005/gitlab-org/gitlab-test.git",
    "visibility_level": 20
  }
}

@gmessner
Copy link
Collaborator Author

@maguro
4.11.1 is now available. The fix supports both the documented (job) and the actual (build) format of the event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant