Add a system hook for when a project is updated.
This sends a project_update hook when a repo is updated. This does not include renaming or transferring a project. Those are covered by project_rename and project_transfer. This will get called, however, when the visibility is changed.
This commit is contained in:
parent
a1c27c2030
commit
0de335eced
4 changed files with 26 additions and 1 deletions
|
@ -22,6 +22,8 @@ module Projects
|
||||||
if project.update_attributes(params.except(:default_branch))
|
if project.update_attributes(params.except(:default_branch))
|
||||||
if project.previous_changes.include?('path')
|
if project.previous_changes.include?('path')
|
||||||
project.rename_repo
|
project.rename_repo
|
||||||
|
else
|
||||||
|
system_hook_service.execute_hooks_for(project, :update)
|
||||||
end
|
end
|
||||||
|
|
||||||
success
|
success
|
||||||
|
|
4
changelogs/unreleased/add_project_update_hook.yml
Normal file
4
changelogs/unreleased/add_project_update_hook.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
title: Add system hook for when a project is updated (other than rename/transfer)
|
||||||
|
merge_request: 5711
|
||||||
|
author: Tommy Beadle
|
|
@ -1,6 +1,6 @@
|
||||||
# System hooks
|
# System hooks
|
||||||
|
|
||||||
Your GitLab instance can perform HTTP POST requests on the following events: `project_create`, `project_destroy`, `project_rename`, `project_transfer`, `user_add_to_team`, `user_remove_from_team`, `user_create`, `user_destroy`, `key_create`, `key_destroy`, `group_create`, `group_destroy`, `user_add_to_group` and `user_remove_from_group`.
|
Your GitLab instance can perform HTTP POST requests on the following events: `project_create`, `project_destroy`, `project_rename`, `project_transfer`, `project_update`, `user_add_to_team`, `user_remove_from_team`, `user_create`, `user_destroy`, `key_create`, `key_destroy`, `group_create`, `group_destroy`, `user_add_to_group` and `user_remove_from_group`.
|
||||||
|
|
||||||
System hooks can be used, e.g. for logging or changing information in a LDAP server.
|
System hooks can be used, e.g. for logging or changing information in a LDAP server.
|
||||||
|
|
||||||
|
@ -88,6 +88,23 @@ X-Gitlab-Event: System Hook
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Project updated:**
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"created_at": "2012-07-21T07:30:54Z",
|
||||||
|
"updated_at": "2012-07-21T07:38:22Z",
|
||||||
|
"event_name": "project_update",
|
||||||
|
"name": "StoreCloud",
|
||||||
|
"owner_email": "johnsmith@gmail.com",
|
||||||
|
"owner_name": "John Smith",
|
||||||
|
"path": "storecloud",
|
||||||
|
"path_with_namespace": "jsmith/storecloud",
|
||||||
|
"project_id": 74,
|
||||||
|
"project_visibility": "private",
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
**New Team Member:**
|
**New Team Member:**
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
|
|
@ -12,6 +12,7 @@ describe SystemHooksService, services: true do
|
||||||
it { expect(event_data(user, :create)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username) }
|
it { expect(event_data(user, :create)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username) }
|
||||||
it { expect(event_data(user, :destroy)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username) }
|
it { expect(event_data(user, :destroy)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username) }
|
||||||
it { expect(event_data(project, :create)).to include(:event_name, :name, :created_at, :updated_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) }
|
it { expect(event_data(project, :create)).to include(:event_name, :name, :created_at, :updated_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) }
|
||||||
|
it { expect(event_data(project, :update)).to include(:event_name, :name, :created_at, :updated_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) }
|
||||||
it { expect(event_data(project, :destroy)).to include(:event_name, :name, :created_at, :updated_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) }
|
it { expect(event_data(project, :destroy)).to include(:event_name, :name, :created_at, :updated_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) }
|
||||||
it { expect(event_data(project_member, :create)).to include(:event_name, :created_at, :updated_at, :project_name, :project_path, :project_path_with_namespace, :project_id, :user_name, :user_username, :user_email, :user_id, :access_level, :project_visibility) }
|
it { expect(event_data(project_member, :create)).to include(:event_name, :created_at, :updated_at, :project_name, :project_path, :project_path_with_namespace, :project_id, :user_name, :user_username, :user_email, :user_id, :access_level, :project_visibility) }
|
||||||
it { expect(event_data(project_member, :destroy)).to include(:event_name, :created_at, :updated_at, :project_name, :project_path, :project_path_with_namespace, :project_id, :user_name, :user_username, :user_email, :user_id, :access_level, :project_visibility) }
|
it { expect(event_data(project_member, :destroy)).to include(:event_name, :created_at, :updated_at, :project_name, :project_path, :project_path_with_namespace, :project_id, :user_name, :user_username, :user_email, :user_id, :access_level, :project_visibility) }
|
||||||
|
@ -68,6 +69,7 @@ describe SystemHooksService, services: true do
|
||||||
it { expect(event_name(project, :destroy)).to eq "project_destroy" }
|
it { expect(event_name(project, :destroy)).to eq "project_destroy" }
|
||||||
it { expect(event_name(project, :rename)).to eq "project_rename" }
|
it { expect(event_name(project, :rename)).to eq "project_rename" }
|
||||||
it { expect(event_name(project, :transfer)).to eq "project_transfer" }
|
it { expect(event_name(project, :transfer)).to eq "project_transfer" }
|
||||||
|
it { expect(event_name(project, :update)).to eq "project_update" }
|
||||||
it { expect(event_name(project_member, :create)).to eq "user_add_to_team" }
|
it { expect(event_name(project_member, :create)).to eq "user_add_to_team" }
|
||||||
it { expect(event_name(project_member, :destroy)).to eq "user_remove_from_team" }
|
it { expect(event_name(project_member, :destroy)).to eq "user_remove_from_team" }
|
||||||
it { expect(event_name(key, :create)).to eq 'key_create' }
|
it { expect(event_name(key, :create)).to eq 'key_create' }
|
||||||
|
|
Loading…
Reference in a new issue