* Rename gitlabModel::createWebhook to initWebhooks.
This commit is contained in:
@@ -794,7 +794,7 @@ class gitlabModel extends model
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function createWebhook($products, $gitlabID, $projectID)
|
||||
public function initWebhooks($products, $gitlabID, $projectID)
|
||||
{
|
||||
$gitlab = $this->getByID($gitlabID);
|
||||
$webhooks = $this->apiGetHooks($gitlabID, $projectID);
|
||||
@@ -822,14 +822,9 @@ class gitlabModel extends model
|
||||
{
|
||||
$object = $this->loadModel($objectType)->getByID($objectID);
|
||||
if(empty($object)) return false;
|
||||
if(!$gitlabID or !$projectID)
|
||||
{
|
||||
$result = $this->getRelationByObject($objectType, $objectID);
|
||||
$gitlabID = $result->gitlabID;
|
||||
$projectID = $result->projectID;
|
||||
}
|
||||
if(!$gitlabID or !$projectID) return false;
|
||||
|
||||
$syncedIssue = $this->getSyncedIssue($objectType = $objectType, $objectID = $objectID, $gitlabID);
|
||||
$syncedIssue = $this->getRelationByObject($objectType, $objectID);
|
||||
$issue = $this->parseObjectToIssue($gitlabID, $projectID, $object, $objectType);
|
||||
if($syncedIssue) return $this->apiUpdateIssue($gitlabID, $projectID, $syncedIssue->BID, $issue);
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ class repoModel extends model
|
||||
$this->loadModel("gitlab")->saveProjectRelation($this->post->product, $this->post->gitlabHost, $this->post->gitlabProject);
|
||||
|
||||
/* create webhook for zentao */
|
||||
$this->loadModel("gitlab")->createWebhook($this->post->product, $this->post->gitlabHost, $this->post->gitlabProject);
|
||||
$this->loadModel("gitlab")->initWebhooks($this->post->product, $this->post->gitlabHost, $this->post->gitlabProject);
|
||||
}
|
||||
return $this->dao->lastInsertID();
|
||||
}
|
||||
@@ -298,7 +298,7 @@ class repoModel extends model
|
||||
{
|
||||
$this->dao->delete()->from(TABLE_REPOHISTORY)->where('repo')->eq($id)->exec();
|
||||
$this->dao->delete()->from(TABLE_REPOFILES)->where('repo')->eq($id)->exec();
|
||||
if($repo->SCM == 'Gitlab') $this->loadModel("gitlab")->createWebhook($this->post->product, $this->post->gitlabHost, $this->post->gitlabProject);
|
||||
if($repo->SCM == 'Gitlab') $this->loadModel("gitlab")->initWebhooks($this->post->product, $this->post->gitlabHost, $this->post->gitlabProject);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -4991,4 +4991,30 @@ class upgradeModel extends model
|
||||
$this->dao->update(TABLE_PRODUCT)->set('createdVersion')->eq($this->config->version)->where('createdVersion')->eq('')->exec();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function processGitlabRepo()
|
||||
{
|
||||
$repoList = $this->dao->select('*')->from(TABLE_REPO)->where('SCM')->eq('Gitlab')->fetchAll();
|
||||
foreach($repoList as $repo)
|
||||
{
|
||||
/* Create gitlab from repo. */
|
||||
$gitlab = new stdclass;
|
||||
$gitlab->type = 'gitlab';
|
||||
$gitlab->name = $repo->client;
|
||||
$gitlab->token = base64_decode($repo->password);
|
||||
$gitlab->private = md5(uniqid());
|
||||
$this->dao->insert(TABLE_PIPELINE)->data($gitlab)->exec();
|
||||
|
||||
$gitlabID = $this->dao->lastInsertID();
|
||||
|
||||
preg_match('/projects\/(\d+)\/repository/', $repo->path, $matches);
|
||||
$gitlabProject = $matches[1];
|
||||
$products = explode(',', $repo->product);
|
||||
$this->loadModel('gitlab')->saveProjectRelation($products, $gitlabID, $gitlabProject);
|
||||
|
||||
$this->dao->update(TABLE_REPO)->set('client')->eq($gitlabID)->set('path')->eq($gitlabProject)->where('id')->eq($repo->id)->exec();
|
||||
|
||||
$this->loadModel("gitlab")->initWebhooks($products, $gitlabID, $gitlabProject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user