* Add page of runPipeline and related funcs.
This commit is contained in:
@@ -249,6 +249,32 @@ class job extends control
|
||||
die(js::reload('parent'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Run GitLab pipeline for a job.
|
||||
*
|
||||
* @param int $id
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function runPipeline($id)
|
||||
{
|
||||
$job = $this->job->getByID($id);
|
||||
if($_POST)
|
||||
{
|
||||
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
|
||||
}
|
||||
$refList = array();
|
||||
$branches = $this->loadModel('gitlab')->apiGetBranches($job->server, $job->pipeline);
|
||||
$tags = $this->loadModel('gitlab')->apiGetTags($job->server, $job->pipeline);
|
||||
foreach($branches as $branch) $refList[] = $branch->name;
|
||||
foreach($tags as $tag) $refList[] = $tag->name;
|
||||
|
||||
$this->view->title = $this->lang->job->runPipeline;
|
||||
$this->view->refList = $refList;
|
||||
$this->view->pipelineTips = $this->lang->job->pipeline->pipelineTips;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX: Get product by repo.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
function addVariable(obj)
|
||||
{
|
||||
var $inputRow = $(obj).closest('.row-module');
|
||||
var $newRow = $('#insertItemBox').clone().insertAfter($inputRow).addClass('highlight');
|
||||
$newRow.find("input[type!='hidden']").val('');
|
||||
setTimeout(function()
|
||||
{
|
||||
$newRow.removeClass('highlight');
|
||||
}, 1600);
|
||||
}
|
||||
|
||||
function deleteVariable(obj)
|
||||
{
|
||||
var $inputRow = $(obj).closest('.row-module');
|
||||
$inputRow.remove();
|
||||
}
|
||||
@@ -4,6 +4,7 @@ $lang->job->browse = '浏览构建任务';
|
||||
$lang->job->create = '创建构建任务';
|
||||
$lang->job->edit = '编辑构建任务';
|
||||
$lang->job->exec = '执行构建';
|
||||
$lang->job->runPipeline = '运行流水线';
|
||||
$lang->job->view = '执行详情';
|
||||
$lang->job->delete = '删除构建任务';
|
||||
$lang->job->confirmDelete = '确认删除该构建任务';
|
||||
@@ -80,3 +81,9 @@ $lang->job->engineTips = new stdclass;
|
||||
$lang->job->engineTips->success = '构建引擎将使用GitLab项目内置的流水线.';
|
||||
$lang->job->engineTips->error = '当前GitLab项目内没有可用的流水线,请先前往GitLab配置.';
|
||||
|
||||
$lang->job->pipeline = new stdclass;
|
||||
$lang->job->pipeline->pipelineTips = "选择要运行流水线的分支名或标签名";
|
||||
$lang->job->pipeline->variables = "变量";
|
||||
$lang->job->pipeline->variablesKeyPlaceHolder = "输入变量的名称";
|
||||
$lang->job->pipeline->variablesValuePlaceHolder = "输入变量的值";
|
||||
$lang->job->pipeline->variablesTips = "指定要在此次运行中使用的变量值。CI/CD设置中指定的值将用作默认值.";
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<form id='childrenForm' method='post' target='hiddenwin'>
|
||||
<table class='table table-form table-auto'>
|
||||
<tr>
|
||||
<td><?php echo $pipelineTips;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='required'><?php echo html::select("references", $refList, '', "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo $lang->job->pipeline->variables; ?></td>
|
||||
</tr>
|
||||
<tr id='insertItemBox' class='row-module'>
|
||||
<td><?php echo html::input("keys[]", '', "class='form-control' placeholder='{$lang->job->pipeline->variablesKeyPlaceHolder}'");?></td>
|
||||
<td><?php echo html::input("values[]", '', "class='form-control' placeholder='{$lang->job->pipeline->variablesValuePlaceHolder}'");?></td>
|
||||
<td><button type="button" class="btn btn-link btn-icon btn-add" onclick="addVariable(this)"><i class="icon icon-plus"></i></button></td>
|
||||
<td><button type="button" class="btn btn-link btn-icon btn-delete" onclick="deleteVariable(this)"><i class="icon icon-close"></i></button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo $lang->job->pipeline->variablesTips; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<?php
|
||||
echo html::submitButton($lang->job->runPipeline);
|
||||
?>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
Reference in New Issue
Block a user