diff --git a/module/job/control.php b/module/job/control.php index 9b92293dd6..0694b9f9eb 100644 --- a/module/job/control.php +++ b/module/job/control.php @@ -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. * diff --git a/module/job/js/runpipeline.js b/module/job/js/runpipeline.js new file mode 100644 index 0000000000..e8e3153061 --- /dev/null +++ b/module/job/js/runpipeline.js @@ -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(); +} diff --git a/module/job/lang/zh-cn.php b/module/job/lang/zh-cn.php index 9a2e648e43..0988bfb309 100644 --- a/module/job/lang/zh-cn.php +++ b/module/job/lang/zh-cn.php @@ -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设置中指定的值将用作默认值."; diff --git a/module/job/view/runpipeline.html.php b/module/job/view/runpipeline.html.php new file mode 100644 index 0000000000..66a760060b --- /dev/null +++ b/module/job/view/runpipeline.html.php @@ -0,0 +1,32 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + +
job->pipeline->variables; ?>
job->pipeline->variablesKeyPlaceHolder}'");?>job->pipeline->variablesValuePlaceHolder}'");?>
job->pipeline->variablesTips; ?>
+ job->runPipeline); + ?> +
+
+