This commit is contained in:
dingguodong
2021-11-23 19:40:42 +08:00
13 changed files with 72 additions and 10 deletions
+1
View File
@@ -32,6 +32,7 @@ $config->action->objectNameFields['budget'] = 'name';
$config->action->objectNameFields['job'] = 'name';
$config->action->objectNameFields['team'] = 'name';
$config->action->objectNameFields['pipeline'] = 'name';
$config->action->objectNameFields['mr'] = 'title';
$config->action->commonImgSize = 870;
+1
View File
@@ -114,6 +114,7 @@ $lang->action->objectTypes['whitelist'] = 'Whitelist';
$lang->action->objectTypes['pipeline'] = 'GitLab';
$lang->action->objectTypes['gitlab'] = 'GitLab';
$lang->action->objectTypes['jenkins'] = 'Jenkins';
$lang->action->objectTypes['mr'] = 'Merge Request';
/* Used to describe operation history. */
$lang->action->desc = new stdclass();
+3
View File
@@ -114,6 +114,7 @@ $lang->action->objectTypes['whitelist'] = '白名单';
$lang->action->objectTypes['pipeline'] = 'GitLab';
$lang->action->objectTypes['gitlab'] = 'GitLab';
$lang->action->objectTypes['jenkins'] = 'Jenkins';
$lang->action->objectTypes['mr'] = '合并请求';
/* 用来描述操作历史记录。*/
$lang->action->desc = new stdclass();
@@ -281,6 +282,8 @@ $lang->action->label->commitsummary = '提交培训总结';
$lang->action->label->updatetrainee = '更新培训人员';
$lang->action->label->createmr = 'MR关联了';
$lang->action->label->mergedmr = 'MR合并了';
$lang->action->label->compilepass = '构建成功';
$lang->action->label->compilefail = '构建失败';
/* 动态信息按照对象分组 */
$lang->action->dynamicAction = new stdclass();
+8
View File
@@ -157,6 +157,14 @@ class ciModel extends model
$this->dao->update(TABLE_COMPILE)->data($data)->where('id')->eq($compile->id)->exec();
$this->dao->update(TABLE_JOB)->set('lastExec')->eq($now)->set('lastStatus')->eq($pipeline->status)->where('id')->eq($compile->job)->exec();
/* Send mr message by compile status. */
$relateMR = $this->dao->select('*')->from(TABLE_MR)->where('compileID')->eq($compile->id)->fetch();
if($relateMR)
{
if($data->status == 'success') $this->loadModel('action')->create('mr', $relateMR->id, 'compilePass');
if($data->status == 'failed') $this->loadModel('action')->create('mr', $relateMR->id, 'compileFail');
}
}
/**
+2 -2
View File
@@ -149,7 +149,7 @@ class compileModel extends model
*/
public function exec($compile)
{
$job = $this->dao->select('t1.id,t1.name,t1.repo,t1.engine,t1.pipeline,t2.name as jenkinsName,t2.url,t2.account,t2.token,t2.password')
$job = $this->dao->select('t1.id,t1.name,t1.repo,t1.engine,t1.pipeline,t2.name as jenkinsName,t2.url,t2.account,t2.token,t2.password,t1.triggerType,t1.customParam,t1.server')
->from(TABLE_JOB)->alias('t1')
->leftJoin(TABLE_PIPELINE)->alias('t2')->on('t1.server=t2.id')
->where('t1.id')->eq($compile->job)
@@ -162,7 +162,7 @@ class compileModel extends model
if($job->triggerType == 'tag')
{
$lastTag = $this->loadModel('job')->getLastTagByRepo($repo);
$lastTag = $this->loadModel('job')->getLastTagByRepo($repo, $job);
if($lastTag)
{
$job->lastTag = $lastTag;
+25 -2
View File
@@ -741,14 +741,37 @@ class mailModel extends model
}
else
{
$sendUsers = $this->{$objectType}->getToAndCcList($object);
$sendUsers = $this->{$objectType}->getToAndCcList($object);
}
if(!$sendUsers) return;
list($toList, $ccList) = $sendUsers;
/* Send it. */
$this->send($toList, $subject, $mailContent, $ccList);
if($objectType == 'mr')
{
$MRLink = common::getSysURL() . helper::createLink('mr', 'view', "id={$object->id}");
if($action->action == 'compilepass')
{
$mailContent = sprintf($this->lang->mr->toCreatedMessage, $MRLink, $title);
$this->send($toList, $subject, $mailContent);
$mailContent = sprintf($this->lang->mr->toReviewerMessage, $MRLink, $title);
$this->send($ccList, $subject, $mailContent);
/* Create a todo item for this MR. */
$this->loadModel('mr')->apiCreateMRTodo($object->gitlabID, $object->targetProject, $object->mriid);
}
elseif($action->action == 'compilefail')
{
$mailContent = sprintf($this->lang->mr->failMessage, $MRLink, $title);
$this->send($toList, $subject, $mailContent, $ccList);
}
}
else
{
$this->send($toList, $subject, $mailContent, $ccList);
}
if($this->isError()) error_log(join("\n", $this->getError()));
}
+3
View File
@@ -11,6 +11,7 @@ $config->message->objectTypes['testtask'] = array('opened', 'edited', 'starte
$config->message->objectTypes['todo'] = array('opened', 'edited');
$config->message->objectTypes['doc'] = array('created', 'edited');
$config->message->objectTypes['release'] = array('opened', 'edited');
$config->message->objectTypes['mr'] = array('compilepass', 'compilefail');
$config->message->available = array();
$config->message->available['mail']['story'] = $config->message->objectTypes['story'];
@@ -19,6 +20,7 @@ $config->message->available['mail']['bug'] = $config->message->objectTypes[
$config->message->available['mail']['testtask'] = array('opened', 'edited', 'closed');
$config->message->available['mail']['doc'] = $config->message->objectTypes['doc'];
$config->message->available['mail']['release'] = $config->message->objectTypes['release'];
$config->message->available['mail']['mr'] = $config->message->objectTypes['mr'];
$config->message->available['webhook'] = $config->message->objectTypes;
@@ -29,6 +31,7 @@ $config->message->available['message']['testtask'] = $config->message->objectTyp
$config->message->available['message']['todo'] = $config->message->objectTypes['todo'];
$config->message->available['message']['doc'] = $config->message->objectTypes['doc'];
$config->message->available['message']['release'] = $config->message->objectTypes['release'];
$config->message->available['message']['mr'] = $config->message->objectTypes['mr'];
$config->message->typeLink = array();
$config->message->typeLink['mail'] = 'mail|index';
+2
View File
@@ -41,3 +41,5 @@ $lang->message->label->canceled = 'cancel';
$lang->message->label->restarted = 'continue';
$lang->message->label->blocked = 'block';
$lang->message->label->bugconfirmed = 'confirm';
$lang->message->label->compilepass = 'compile pass';
$lang->message->label->compilefail = 'compile fail';
+2
View File
@@ -41,3 +41,5 @@ $lang->message->label->canceled = '取消';
$lang->message->label->restarted = '继续';
$lang->message->label->blocked = '阻塞';
$lang->message->label->bugconfirmed = '确认';
$lang->message->label->compilepass = '构建通过';
$lang->message->label->compilefail = '构建失败';
+1
View File
@@ -163,6 +163,7 @@ class messageModel extends model
if(empty($toList) and $objectType == 'todo') $toList = $object->account;
if(empty($toList) and $objectType == 'testtask') $toList = $object->owner;
if(empty($toList) and $objectType == 'meeting') $toList = $object->host . $object->participant;
if(empty($toList) and $objectType == 'mr') $toList = $object->createdBy . ',' . $object->assignee;
if(empty($toList) and $objectType == 'release')
{
/* Get notifiy persons. */
+5 -2
View File
@@ -71,8 +71,11 @@ $lang->mr->sourceBranch = 'Source branch';
$lang->mr->targetProject = 'Target project';
$lang->mr->targetBranch = 'Target branch';
$lang->mr->usersTips = 'Tip: If you cannot choose the assignee, please go to the GitLab page to bind the user first.';
$lang->mr->notFound = "Merge Request does not exist!";
$lang->mr->usersTips = 'Tip: If you cannot choose the assignee, please go to the GitLab page to bind the user first.';
$lang->mr->notFound = "Merge Request does not exist!";
$lang->mr->toCreatedMessage = "The merge request you submitted:<a href='%s'>%s</a>, the build task succeeded.";
$lang->mr->toReviewerMessage = "有一个合并请求:<a href='%s'>%s</a> 待审核。";
$lang->mr->failMessage = "您提交的合并请求:<a href='%s'>%s</a> 构建任务执行失败,查看执行结果。";
$lang->mr->apiError = new stdclass;
$lang->mr->apiError->createMR = "Failed to create a merge request through API. Reason: %s";
+5 -2
View File
@@ -77,8 +77,11 @@ $lang->mr->targetBranch = '目标分支';
$lang->mr->noCompileJob = '没有构建任务';
$lang->mr->compileUnexecuted = '还未执行';
$lang->mr->usersTips = '提示:如果无法选择指派人,请先前往GitLab页面绑定用户。';
$lang->mr->notFound = "此{$lang->mr->common}不存在。";
$lang->mr->usersTips = '提示:如果无法选择指派人,请先前往GitLab页面绑定用户。';
$lang->mr->notFound = "此{$lang->mr->common}不存在。";
$lang->mr->toCreatedMessage = "您提交的合并请求:<a href='%s'>%s</a> 构建任务执行通过。";
$lang->mr->toReviewerMessage = "有一个合并请求:<a href='%s'>%s</a> 待审核。";
$lang->mr->failMessage = "您提交的合并请求:<a href='%s'>%s</a> 构建任务执行失败,查看执行结果。";
$lang->mr->apiError = new stdclass;
$lang->mr->apiError->createMR = "通过API创建合并请求失败,失败原因:%s";
+14 -2
View File
@@ -45,7 +45,7 @@ class mrModel extends model
* @access public
* @return array
*/
public function getList($mode = 'all', $param = 'all', $orderBy = 'id_desc', $pager)
public function getList($mode = 'all', $param = 'all', $orderBy = 'id_desc', $pager = null)
{
$MRList = $this->dao->select('*')
->from(TABLE_MR)
@@ -158,7 +158,7 @@ class mrModel extends model
}
/* Create a todo item for this MR. */
$this->apiCreateMRTodo($this->post->gitlabID, $this->post->targetProject, $rawMR->iid);
if(empty($MR->jobID)) $this->apiCreateMRTodo($this->post->gitlabID, $this->post->targetProject, $rawMR->iid);
$newMR = new stdclass;
$newMR->mriid = $rawMR->iid;
@@ -1149,6 +1149,18 @@ class mrModel extends model
return $product;
}
/**
* Get toList and ccList.
*
* @param object $mr
* @access public
* @return bool|array
*/
public function getToAndCcList($mr)
{
return array($mr->createdBy, $mr->assignee);
}
/**
* Log merged action to links.
*