+ Add webhook api for gitfox.

This commit is contained in:
caoyanyi
2024-03-13 14:19:42 +08:00
parent 17e265855b
commit af974c9c8a
3 changed files with 42 additions and 3 deletions
+38
View File
@@ -0,0 +1,38 @@
<?php
/**
* The repo entry point of ZenTaoPMS.
*
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
* @author xiawenlong <xiawenlong@cnezsoft.com>
* @package repo
* @version 1
* @link https://www.zentao.net
*/
class gitfoxWebhookEntry extends baseEntry
{
/**
* Repo webhook.
*
* @access public
* @return string
*/
public function post()
{
$headers = getallheaders(); /* Fetch all HTTP request headers. */
$event = isset($headers['X-Gitness-Trigger']) ? $headers['X-Gitness-Trigger'] : '';
if(empty($event)) return;
$repoID = $this->param('repoID');
if(empty($repoID)) return;
$this->app->user = new stdclass();
$this->app->user->account = '';
$this->app->user->admin = false;
$repo = $this->loadModel('repo')->getByID($repoID);
if(empty($repo)) return;
$this->repo->handleWebhook($event, $this->requestBody, $repo);
}
}
+3 -3
View File
@@ -27,12 +27,12 @@ class gitlabWebhookEntry extends baseEntry
$repoID = $this->param('repoID');
if(empty($repoID)) return;
$repo = $this->loadModel('repo')->getByID($repoID);
if(empty($repo)) return;
$this->app->user = new stdclass();
$this->app->user->account = '';
$this->app->user->admin = false;
$repo = $this->loadModel('repo')->getByID($repoID);
if(empty($repo)) return;
$this->repo->handleWebhook($event, $this->requestBody, $repo);
}
}
+1
View File
@@ -178,6 +178,7 @@ $routes['/z/files/:id'] = 'zfile';
$routes['/z/files/:id/content'] = 'zfileContent';
$routes['/gitlab/webhook'] = 'gitlabWebhook';
$routes['/gitfox/webhook'] = 'gitfoxWebhook';
$routes['/ciresults'] = 'ciresults';