From daf877dfb669ec54d81a7a241edce4775bdf7615 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Thu, 22 Jul 2021 09:30:46 +0800 Subject: [PATCH] * Add gitlab to pipeline job(staging). --- module/job/control.php | 3 ++- module/job/js/create.js | 48 ++++++++++++++++++++++++++------- module/job/lang/zh-cn.php | 11 ++++++++ module/job/view/create.html.php | 46 ++++++++++++++++++++----------- 4 files changed, 83 insertions(+), 25 deletions(-) diff --git a/module/job/control.php b/module/job/control.php index 5baf3183da..e471064b96 100644 --- a/module/job/control.php +++ b/module/job/control.php @@ -86,7 +86,8 @@ class job extends control $this->view->repoPairs = $repoPairs; $this->view->repoTypes = $repoTypes; $this->view->products = array(0 => '') + $this->loadModel('product')->getProductPairsByProject($this->projectID); - $this->view->serverList = $this->loadModel('jenkins')->getPairs(); + + $this->view->jenkinsServerList = $this->loadModel('jenkins')->getPairs(); $this->display(); } diff --git a/module/job/js/create.js b/module/job/js/create.js index 517b7eab3a..1e4801e4bf 100644 --- a/module/job/js/create.js +++ b/module/job/js/create.js @@ -82,13 +82,13 @@ $('#triggerType').change(function() } }); -$('#server').change(function() +$('#gitlabServer').change(function() { - var jenkinsID = $(this).val(); - $('#pipelineBox #pipeline').remove(); - $('#pipelineBox #pipeline_chosen').remove(); - $('#pipelineBox .input-group').append("
"); - $.getJSON(createLink('jenkins', 'ajaxGetTasks', 'jenkinsID=' + jenkinsID), function(tasks) + var repoID = $('#repo').val(); + $('#gitlabServerTR #pipeline').remove(); + $('#gitlabServerTR #pipeline_chosen').remove(); + $('#gitlabServerTR .input-group').append("
"); + $.getJSON(createLink('gitlab', 'ajaxGetGitlabPipeline', 'repoID=' + repoID), function(tasks) { html = "'; - $('#pipelineBox .loading').remove(); - $('#pipelineBox .input-group').append(html); + $('#gitlabServerTR .loading').remove(); + $('#gitlabServerTR .input-group').append(html); - $('#pipelineBox #pipeline').chosen({drop_direction: 'auto'}); + $('#gitlabServerTR #pipeline').chosen({drop_direction: 'auto'}); }) }) +$('#jkServer').change(function() +{ + var jenkinsID = $(this).val(); + $('#jenkinsServerTR #JkTask').remove(); + $('#jenkinsServerTR #JkTask_chosen').remove(); + $('#jenkinsServerTR .input-group').append("
"); + $.getJSON(createLink('jenkins', 'ajaxGetJenkinsTasks', 'jenkinsID=' + jenkinsID), function(tasks) + { + html = "'; + $('#jenkinsServerTR .loading').remove(); + $('#jenkinsServerTR .input-group').append(html); + + $('#jenkinsServerTR #JkTask').chosen({drop_direction: 'auto'}); + }) +}) + +$('#engine').change(function() +{ + $('#jenkinsServerTR').toggle($('#engine').val() == 'jenkins'); + $('#gitlabServerTR').toggle($('#engine').val() == 'gitlab'); +}); + +$('#engine').change(); + $(function() { $('#triggerType').change(); diff --git a/module/job/lang/zh-cn.php b/module/job/lang/zh-cn.php index 4fa94783f1..7c49a0ea49 100644 --- a/module/job/lang/zh-cn.php +++ b/module/job/lang/zh-cn.php @@ -68,3 +68,14 @@ $lang->job->paramValueList['$zentao_version'] = '当前版本号'; $lang->job->paramValueList['$zentao_account'] = '当前用户名'; $lang->job->paramValueList['$zentao_product'] = '当前产品ID'; $lang->job->paramValueList['$zentao_repopath'] = '当前版本库路径'; + + +$lang->job->engineList = array(); +$lang->job->engineList[''] = ''; +$lang->job->engineList['gitlab'] = 'GitLab'; +$lang->job->engineList['jenkins'] = 'Jenkins'; + +$lang->job->engineTips = new stdclass; +$lang->job->engineTips->success = '构建引擎将使用GitLab项目内置的流水线'; +$lang->job->engineTips->error = '当前GitLab项目内没有可用的流水线,请先前往GitLab配置'; + diff --git a/module/job/view/create.html.php b/module/job/view/create.html.php index 83d2d51bac..2697ebedc0 100644 --- a/module/job/view/create.html.php +++ b/module/job/view/create.html.php @@ -30,7 +30,7 @@ - + job->repo; ?> @@ -39,6 +39,36 @@ + job->engine; ?> + +
+
job->engineList, '', "class='form-control chosen'"); ?>
+
+ + + + + job->server; ?> + +
+
+
+
+ job->pipeline; ?> + ''), '', "class='form-control chosen'"); ?> +
+
+
+ + + + job->server; ?> + + + + + + job->frame; ?> job->frameList, '', "class='form-control chosen'"); ?> @@ -72,20 +102,6 @@ - - job->server; ?> - -
-
-
-
- job->pipeline; ?> - ''), '', "class='form-control chosen'"); ?> -
-
-
- - job->customParam;?>