* Finish importing issue to zentao bug(staging).

This commit is contained in:
dingguodong
2021-07-08 14:30:28 +08:00
parent 832e9b1cf1
commit 129e14bf30
5 changed files with 65 additions and 5 deletions
+1
View File
@@ -2,6 +2,7 @@
$config->bug = new stdClass();
$config->bug->batchCreate = 10;
$config->bug->longlife = 7;
$config->bug->removeFields= 'objectTypeList,productList,executionList,gitlabID,gitlabProjectID';
$config->bug->create = new stdclass();
$config->bug->edit = new stdclass();
+45
View File
@@ -273,6 +273,51 @@ class bugModel extends model
return $actions;
}
/**
* Create bug from gitlab issue.
*
* @param object $bug
* @param int $executionID
* @access public
* @return int
*/
public function createBugFromGitlabIssue($bug, $executionID)
{
foreach($bug as $feild => $value) $_POST[$feild] = $value;
$now = helper::now();
$bug = fixer::input('post')
->setDefault('openedBy', $this->app->user->account)
->setDefault('openedDate', $now)
->setDefault('project,execution,story,task', 0)
->setDefault('openedBuild', '1') // todo(dingguodong) openedBuild is hard-coded.
->setDefault('deadline', '0000-00-00')
->setIF($this->config->systemMode == 'new' && $this->lang->navGroup->bug != 'qa', 'project', $this->session->project)
->setIF(strpos($this->config->bug->create->requiredFields, 'deadline') !== false, 'deadline', $bug->deadline)
->setIF(isset($bug->assignedTo) and $bug->assignedTo != '', 'assignedDate', $now)
->stripTags($this->config->bug->editor->create['id'], $this->config->allowedTags)
->cleanInt('product,execution,module,severity')
->join('openedBuild', ',')
->join('mailto', ',')
->remove('files, labels,uid,oldTaskID,contactListMenu')
->remove($this->config->bug->removeFields)
->get();
if($executionID != 0)
{
$bug->project = $this->dao->select('parent')->from(TABLE_EXECUTION)->where('id')->eq($executionID)->fetch('parent');
$bug->execution = $executionID;
}
$this->dao->insert(TABLE_BUG)->data($bug, $skip = 'gitlab,gitlabProject')->autoCheck()->batchCheck($this->config->bug->create->requiredFields, 'notempty')->exec();
if(!dao::isError())
{
$bugID = $this->dao->lastInsertID();
return $bugID;
}
return false;
}
/**
* Get bugs.
*
+1
View File
@@ -55,6 +55,7 @@ $config->gitlab->maps->bug = array();
$config->gitlab->maps->bug['title'] = 'title|field|';
$config->gitlab->maps->bug['steps'] = 'description|field|';
$config->gitlab->maps->bug['openedDate'] = 'created_at|field|datetime';
$config->gitlab->maps->bug['deadline'] = 'due_date|field|date';
$config->gitlab->maps->bug['assignedTo'] = 'assignee_id|userPairs|';
$config->gitlab->maps->bug['status'] = 'state|configItems|bugStateMap';
$config->gitlab->maps->bug['pri'] = 'weight|configItems|bugWeightMap';
+17 -5
View File
@@ -269,6 +269,8 @@ class gitlab extends control
$executionList = $this->post->executionList;
$objectTypeList = $this->post->objectTypeList;
$productList = $this->post->productList;
$failedIssues = array();
foreach($executionList as $issueID => $executionID)
{
if($executionID)
@@ -281,6 +283,8 @@ class gitlab extends control
$issue->updated_by_id = $issue->author->id; // here can be replaced by current zentao user.
$object = $this->gitlab->issueToZentaoObject($issue, $gitlabID);
$object->product = $productList[$issueID];
$object->execution = $executionID;
if($objectType == 'task')
{
$objectID = $this->loadModel('task')->createTaskFromGitlabIssue($object, $executionID);
@@ -288,23 +292,31 @@ class gitlab extends control
if($objectType == 'bug')
{
$objectID = $this->loadModel('bug')->createBugFromGitlabIssue($object, $executionID);
}
if($objectType == 'story')
{
$objectID = $this->loadModel('story')->createStoryFromGitlabIssue($object, $executionID);
}
$object->id = $objectID;
$object->product = $productList[$issueID];
$object->execution = $executionID;
$this->gitlab->saveImportedIssue($gitlabID, $projectID, $objectType, $objectID, $issue, $object);
if($objectID)
{
$object->id = $objectID;
$this->gitlab->saveImportedIssue($gitlabID, $projectID, $objectType, $objectID, $issue, $object);
}
else
{
$failedIssues[] = $issue->iid;
}
}
else
{
if($productList[$issueID] != 0) $this->send(array('result' => 'fail', 'message' => $this->lang->gitlab->importIssueError, 'locate' => $this->server->http_referer));
}
}
if($failedIssues) $this->send(array('result' => 'success', 'message' => $this->lang->gitlab->importIssueWarn, 'locate' => $this->server->http_referer));
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->server->http_referer));
}
+1
View File
@@ -40,3 +40,4 @@ $lang->gitlab->tokenError = "当前token非管理员权限。";
$lang->gitlab->hostError = "无效的gitlab服务地址。";
$lang->gitlab->bindUserError = "不能重复绑定用户 %s";
$lang->gitlab->importIssueError = "未选择该议题所属的执行。";
$lang->gitlab->importIssueWarn = "存在导入失败的议题,可再次尝试导入。";