finish webhook.

This commit is contained in:
xiawenlong
2021-11-12 09:48:11 +08:00
parent 24966356bc
commit c004b06e1e
8 changed files with 106 additions and 39 deletions

View File

@@ -859,7 +859,7 @@ class gitlabModel extends model
* @param object $hook
* @access public
* @docs https://docs.gitlab.com/ee/api/projects.html#add-project-hook
* @return object
* @return string
*/
public function apiCreateHook($gitlabID, $projectID, $hook)
{
@@ -893,6 +893,27 @@ class gitlabModel extends model
return commonModel::http($url, null, array(CURLOPT_CUSTOMREQUEST => 'delete'));
}
/**
* Add push web hook
*
* @param object $repo`
* @access public
* @return void
*/
public function addPushWebhook($repo)
{
$hook = new stdClass;
$hook->id = $repo->path;
$hook->url = common::getSysURL() . '/api.php/v1/gitlab/webhook?repoID='. $repo->id;
$hook->push_events = true;
$hook->merge_requests_events = true;
$res = $this->apiCreateHook($repo->gitlab, $repo->extra, $hook);
$data = json_decode($res, true);
if(!empty($data['id'])) return true;
return false;
}
/**
* Update hook by api.
*