diff --git a/module/job/control.php b/module/job/control.php index f433b00804..17d166f5d6 100644 --- a/module/job/control.php +++ b/module/job/control.php @@ -102,7 +102,7 @@ class job extends control if(empty($repo->synced)) continue; $repoPairs[$repo->id] = $repo->name; $repoTypes[$repo->id] = $repo->SCM; - if($repo->SCM == 'Gitlab') $gitlabRepos[$repo->id] = $repo->name; + if(strtolower($repo->SCM) == 'gitlab') $gitlabRepos[$repo->id] = $repo->name; } $this->view->title = $this->lang->ci->job . $this->lang->colon . $this->lang->job->create; @@ -161,14 +161,16 @@ class job extends control $repo = $this->loadModel('repo')->getRepoByID($job->repo); $this->view->repo = $this->loadModel('repo')->getRepoByID($job->repo); - $repoList = $this->repo->getList($this->projectID); - $repoPairs = array(0 => '', $repo->id => $repo->name); + $repoList = $this->repo->getList($this->projectID); + $repoPairs = array(0 => '', $repo->id => $repo->name); + $gitlabRepos = array(0 => ''); $repoTypes[$repo->id] = $repo->SCM; foreach($repoList as $repo) { if(empty($repo->synced)) continue; $repoPairs[$repo->id] = $repo->name; $repoTypes[$repo->id] = $repo->SCM; + if(strtolower($repo->SCM) == 'gitlab') $gitlabRepos[$repo->id] = $repo->name; } $products = $this->repo->getProductsByRepo($job->repo); @@ -182,6 +184,7 @@ class job extends control $this->view->position[] = html::a(inlink('browse'), $this->lang->ci->job); $this->view->position[] = $this->lang->job->edit; $this->view->repoPairs = $repoPairs; + $this->view->gitlabRepos = $gitlabRepos; $this->view->repoTypes = $repoTypes; $this->view->repoType = zget($repoTypes, $job->repo, 'Git'); $this->view->job = $job; diff --git a/module/job/js/create.js b/module/job/js/create.js index cc0301ae01..cbe8c58a18 100644 --- a/module/job/js/create.js +++ b/module/job/js/create.js @@ -8,7 +8,7 @@ $(document).ready(function() $('#repo').change(function() { var repoID = $(this).val(); - var link = createLink('repo', 'ajaxLoadPorducts', 'repoID=' + repoID); + var link = createLink('repo', 'ajaxLoadProducts', 'repoID=' + repoID); $.get(link, function(data) { if(data) diff --git a/module/job/js/edit.js b/module/job/js/edit.js index 1f90a1c89c..2b76c48b1c 100644 --- a/module/job/js/edit.js +++ b/module/job/js/edit.js @@ -1,9 +1,14 @@ $(document).ready(function() { + $('#gitlabRepo').change(function() + { + $('#repo').val($(this).val()).change(); + }) + $('#repo').change(function() { var repoID = $(this).val(); - var link = createLink('repo', 'ajaxLoadPorducts', 'repoID=' + repoID); + var link = createLink('repo', 'ajaxLoadProducts', 'repoID=' + repoID); $.get(link, function(data) { if(data) @@ -107,7 +112,7 @@ $(document).ready(function() $('#jenkinsServerTR .input-group').append("
"); $.getJSON(createLink('jenkins', 'ajaxGetJenkinsTasks', 'jenkinsID=' + jenkinsID), function(tasks) { - html = ""; for(taskKey in tasks) { var task = tasks[taskKey]; @@ -130,10 +135,14 @@ $(document).ready(function() if($(this).val() == 'gitlab') { $('#triggerType').find('[value=schedule]').remove(); + $('tr.gitlabRepo').show(); + $('tr.commonRepo').hide(); } else if($('#triggerType').find('[value=schedule]').size() == 0 ) { $('#triggerType').append(scheduleOption); + $('tr.gitlabRepo').hide(); + $('tr.commonRepo').show(); } }); diff --git a/module/job/model.php b/module/job/model.php index c2c99450e5..d372e82698 100644 --- a/module/job/model.php +++ b/module/job/model.php @@ -128,6 +128,7 @@ class jobModel extends model if(strtolower($job->engine) == 'gitlab') { + $job->repo = $job->gitlabRepo; $repo = $this->loadModel('repo')->getRepoByID($job->repo); $job->server = (int)zget($repo, 'gitlab', 0); $job->pipeline = zget($repo, 'project', ''); @@ -135,6 +136,7 @@ class jobModel extends model unset($job->jkServer); unset($job->jkTask); + unset($job->gitlabRepo); if($job->triggerType == 'schedule') $job->atDay = empty($_POST['atDay']) ? '' : join(',', $this->post->atDay); @@ -212,6 +214,7 @@ class jobModel extends model if(strtolower($job->engine) == 'gitlab') { + $job->repo = $job->gitlabRepo; $repo = $this->loadModel('repo')->getRepoByID($job->repo); $job->server = (int)zget($repo, 'gitlab', 0); $job->pipeline = zget($repo, 'project', ''); @@ -219,6 +222,7 @@ class jobModel extends model unset($job->jkServer); unset($job->jkTask); + unset($job->gitlabRepo); if($job->triggerType == 'schedule') $job->atDay = empty($_POST['atDay']) ? '' : join(',', $this->post->atDay); diff --git a/module/job/view/create.html.php b/module/job/view/create.html.php index 8cf317f36e..e7e0090ab5 100644 --- a/module/job/view/create.html.php +++ b/module/job/view/create.html.php @@ -126,7 +126,7 @@ - + goback, '', 'class="btn btn-wide"');?> diff --git a/module/job/view/edit.html.php b/module/job/view/edit.html.php index 14f0d7ae79..82f235fe65 100644 --- a/module/job/view/edit.html.php +++ b/module/job/view/edit.html.php @@ -37,10 +37,13 @@ job->engineList, $job->engine, '') . html::hidden('engine', $job->engine);?> - - job->repo;?> - repo, "class='form-control chosen'");?> - + + job->repo; ?> + repo, "class='form-control'"); ?> + + + job->repo; ?> + repo, "class='form-control'"); ?> job->product;?> @@ -166,7 +169,7 @@ - + goback, '', 'class="btn btn-wide"');?> repo, 'Git'));?> diff --git a/module/repo/control.php b/module/repo/control.php index bd551f9de0..4d61974532 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -1164,7 +1164,7 @@ class repo extends control * @access public * @return void */ - public function ajaxLoadPorducts($repoID) + public function ajaxLoadProducts($repoID) { $productPairs = $this->repo->getProductsByRepo($repoID); echo html::select('product', array('') + $productPairs, key($productPairs), "class='form-control chosen'"); diff --git a/module/repo/model.php b/module/repo/model.php index 56eadabe71..b9609b7fe5 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -288,6 +288,12 @@ class repoModel extends model $this->rmClientVersionFile(); + if($data->SCM == 'Gitlab') + { + $newRepo = $this->getRepoByID($id); + $data->path = $newRepo->path; + } + if($repo->path != $data->path) { $this->dao->delete()->from(TABLE_REPOHISTORY)->where('repo')->eq($id)->exec();