diff --git a/module/gitlab/config.php b/module/gitlab/config.php index 6f7828f459..2f66c83ed7 100644 --- a/module/gitlab/config.php +++ b/module/gitlab/config.php @@ -17,5 +17,7 @@ $config->gitlab->bugLabel->description = "bug label from zentao"; $config->gitlab->bugLabel->color = "#D10069"; $config->gitlab->bugLabel->priority = "0"; +$config->gitlab->zentaoApiWebhookUrl = "https://zentao/api/v1/webhook/callback"; +$config->gitlab->zentaoApiWebhookToken = ""; diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 0488d45cc8..8358d2b929 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -227,6 +227,21 @@ class gitlabModel extends model return $gitlab_url; } + /** + * Create webhook for zentao. + * + * @param int $gitlabID + * @param int $projectID + * @access public + * @return void + */ + public function createWebhook($gitlabID, $projectID) + { + // TODO(dingguodong) add more robust code here. + $response = $this->apiCreateHook($gitlabID, $projectID, $this->config->gitlab->zentaoApiWebhookUrl, $this->config->gitlab->zentaoApiWebhookToken); + return $response; + } + /** * Get hooks. * diff --git a/module/repo/model.php b/module/repo/model.php index e4e512e54a..165533741a 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -235,6 +235,9 @@ class repoModel extends model // save the relationship between zentao product and gitlab project to zt_relation table. + /* create webhook for zentao */ + $this->loadModel("gitlab")->createWebhook($this->post->gitlabHost, $this->post->gitlabProject); + }