Merge branch 'devops17_zenggang' into 'master'
* Code for task#46005 See merge request easycorp/zentaopms!1124
This commit is contained in:
@@ -121,6 +121,7 @@ ALTER TABLE `zt_mr` ADD `synced` enum('0','1') COLLATE 'utf8_general_ci' NOT NUL
|
||||
ALTER TABLE `zt_mr` ADD `hasNoConflict` enum('0','1') COLLATE 'utf8_general_ci' NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `zt_mr` ADD `diffs` longtext COLLATE 'utf8_general_ci' NULL AFTER `synced`;
|
||||
ALTER TABLE `zt_mr` ADD `removeSourceBranch` ENUM('0','1') NOT NULL DEFAULT '0' AFTER `compileStatus`;
|
||||
ALTER TABLE `zt_mr` ADD `syncError` VARCHAR(255) NOT NULL AFTER `synced`;
|
||||
|
||||
ALTER TABLE zt_repo ADD `fileServerUrl` text COLLATE 'utf8_general_ci' NULL AFTER `job`;
|
||||
ALTER TABLE zt_repo ADD `fileServerAccount` varchar(40) NOT NULL default '' AFTER `fileServerUrl`;
|
||||
|
||||
@@ -849,6 +849,7 @@ CREATE TABLE IF NOT EXISTS `zt_mr` (
|
||||
`compileStatus` char(30) NOT NULL,
|
||||
`removeSourceBranch` enum('0','1') NOT NULL DEFAULT '0',
|
||||
`synced` enum('0','1') COLLATE 'utf8_general_ci' NOT NULL DEFAULT '1',
|
||||
`syncError` varchar(255) NOT NULL,
|
||||
`hasNoConflict` enum('0','1') COLLATE 'utf8_general_ci' NOT NULL DEFAULT '0',
|
||||
`diffs` longtext COLLATE 'utf8_general_ci' NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
|
||||
+28
-1
@@ -57,7 +57,7 @@ class ciModel extends model
|
||||
/* Max retry times is: 3. */
|
||||
if($compile->times >= 3)
|
||||
{
|
||||
$this->dao->update(TABLE_COMPILE)->set('status')->eq('failure')->where('id')->eq($compile->id)->exec();
|
||||
$this->updateBuildStatus($compile, 'failure');
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -223,6 +223,33 @@ class ciModel extends model
|
||||
|
||||
$rawMR = $this->loadModel('mr')->apiCreateMR($relateMR->gitlabID, $relateMR->sourceProject, $MRObject);
|
||||
|
||||
/**
|
||||
* Another open merge request already exists for this source branch.
|
||||
* The type of variable `$rawMR->message` is array.
|
||||
*/
|
||||
if(isset($rawMR->message) and !isset($rawMR->iid))
|
||||
{
|
||||
foreach($this->lang->mr->apiErrorMap as $key => $errorMsg)
|
||||
{
|
||||
if(strpos($errorMsg, '/') === 0)
|
||||
{
|
||||
$result = preg_match($errorMsg, $rawMR->message[0], $matches);
|
||||
if($result) $errorMessage = sprintf(zget($this->lang->mr->errorLang, $key), $matches[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if($rawMR->message[0] == $errorMsg) $errorMessage = zget($this->lang->mr->errorLang, $key, $rawMR->message[0]);
|
||||
}
|
||||
|
||||
if(isset($errorMessage)) break;
|
||||
}
|
||||
$newMR->syncError = sprintf($this->lang->mr->apiError->createMR, isset($errorMessage) ? $errorMessage : $rawMR->message[0]);
|
||||
}
|
||||
elseif(!isset($rawMR->iid))
|
||||
{
|
||||
$newMR->syncError = $this->lang->mr->createFailedFromAPI;
|
||||
}
|
||||
|
||||
if(!empty($rawMR->iid))
|
||||
{
|
||||
$newMR->mriid = $rawMR->iid;
|
||||
|
||||
+11
-5
@@ -366,12 +366,12 @@ class jobModel extends model
|
||||
/**
|
||||
* Exec job.
|
||||
*
|
||||
* @param int $id
|
||||
* @param object $reference
|
||||
* @param int $id
|
||||
* @param array $extraParam
|
||||
* @access public
|
||||
* @return string|bool
|
||||
*/
|
||||
public function exec($id)
|
||||
public function exec($id, $extraParam = array())
|
||||
{
|
||||
$job = $this->dao->select('t1.id,t1.name,t1.product,t1.repo,t1.server,t1.pipeline,t1.triggerType,t1.atTime,t1.customParam,t1.engine,t2.name as jenkinsName,t2.url,t2.account,t2.token,t2.password')
|
||||
->from(TABLE_JOB)->alias('t1')
|
||||
@@ -408,7 +408,7 @@ class jobModel extends model
|
||||
$this->dao->insert(TABLE_COMPILE)->data($build)->exec();
|
||||
$compileID = $this->dao->lastInsertId();
|
||||
|
||||
if($job->engine == 'jenkins') $compile = $this->execJenkinsPipeline($job, $repo, $compileID);
|
||||
if($job->engine == 'jenkins') $compile = $this->execJenkinsPipeline($job, $repo, $compileID, $extraParam);
|
||||
if($job->engine == 'gitlab') $compile = $this->execGitlabPipeline($job);
|
||||
|
||||
$this->dao->update(TABLE_COMPILE)->data($compile)->where('id')->eq($compileID)->exec();
|
||||
@@ -428,10 +428,11 @@ class jobModel extends model
|
||||
* @param object $job
|
||||
* @param object $repo
|
||||
* @param int $compileID
|
||||
* @param array $extraParam
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function execJenkinsPipeline($job, $repo, $compileID)
|
||||
public function execJenkinsPipeline($job, $repo, $compileID, $extraParam = array())
|
||||
{
|
||||
$pipeline = new stdclass();
|
||||
$pipeline->PARAM_TAG = '';
|
||||
@@ -449,6 +450,11 @@ class jobModel extends model
|
||||
$pipeline->$paramName = $paramValue;
|
||||
}
|
||||
|
||||
foreach($extraParam as $paramName => $paramValue)
|
||||
{
|
||||
if(!isset($pipeline->$paramName)) $pipeline->$paramName = $paramValue;
|
||||
}
|
||||
|
||||
$url = $this->loadModel('compile')->getBuildUrl($job);
|
||||
|
||||
$compile = new stdclass();
|
||||
|
||||
+6
-2
@@ -225,8 +225,12 @@ class mrModel extends model
|
||||
/* Exec Job */
|
||||
if($MR->hasNoConflict == '0' && $MR->mergeStatus == 'can_be_merged' && $MR->jobID)
|
||||
{
|
||||
$MRID = $this->dao->lastInsertId();
|
||||
$pipeline = $this->loadModel('job')->exec($MR->jobID);
|
||||
$MRID = $this->dao->lastInsertId();
|
||||
|
||||
$extraParam = array();
|
||||
if(!empty($repo->fileServerUrl)) $extraParam = array('ZENTAO_REPOPATH' => $repo->fileServerUrl);
|
||||
|
||||
$pipeline = $this->loadModel('job')->exec($MR->jobID, $extraParam);
|
||||
$newMR = new stdClass();
|
||||
if(!empty($pipeline->queue))
|
||||
{
|
||||
|
||||
@@ -62,7 +62,13 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="w-100px"><?php echo $lang->mr->status;?></th>
|
||||
<td><?php echo zget($lang->mr->statusList, $MR->status);?></td>
|
||||
<td>
|
||||
<?php if(!empty($MR->syncError) and $MR->synced === '0'):?>
|
||||
<span class="text-danger"><?php echo $MR->syncError;?></span>
|
||||
<?php else:?>
|
||||
<?php echo zget($lang->mr->statusList, $MR->status);?>
|
||||
<?php endif;?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->mr->mergeStatus; ?></th>
|
||||
@@ -72,7 +78,7 @@
|
||||
<?php if($MR->synced) echo '<code>' . $lang->mr->noChanges . '</code>';?>
|
||||
</td>
|
||||
<?php else:?>
|
||||
<td><?php echo zget($lang->mr->mergeStatusList, $rawMR->merge_status);?></td>
|
||||
<td><?php echo zget($lang->mr->mergeStatusList, !empty($rawMR->merge_status) ? $rawMR->merge_status : $MR->mergeStatus);?></td>
|
||||
<?php endif;?>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
Reference in New Issue
Block a user