This commit is contained in:
wangyidong
2021-08-05 16:56:47 +08:00
8 changed files with 38 additions and 13 deletions
+6 -3
View File
@@ -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;
+1 -1
View File
@@ -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)
+11 -2
View File
@@ -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("<div class='load-indicator loading'></div>");
$.getJSON(createLink('jenkins', 'ajaxGetJenkinsTasks', 'jenkinsID=' + jenkinsID), function(tasks)
{
html = "<select id='jkTask' name='jkTask' class='form-control'>";
html = "<select id='jkTask' name='jkTask' class='form-control'>";
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();
}
});
+4
View File
@@ -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);
+1 -1
View File
@@ -126,7 +126,7 @@
<th></th>
<td class='text-center form-actions'>
<?php echo html::submitButton(); ?>
<?php echo html::backButton(); ?>
<?php if(!isonlybody()) echo html::a(inlink('browse', ""), $lang->goback, '', 'class="btn btn-wide"');?>
<?php echo html::hidden('repoType');?>
</td>
</tr>
+8 -5
View File
@@ -37,10 +37,13 @@
<td><?php echo zget($lang->job->engineList, $job->engine, '') . html::hidden('engine', $job->engine);?>
</td>
</tr>
<tr>
<th><?php echo $lang->job->repo;?></th>
<td><?php echo html::select('repo', $repoPairs, $job->repo, "class='form-control chosen'");?>
</td>
<tr class='commonRepo'>
<th><?php echo $lang->job->repo; ?></th>
<td><?php echo html::select('repo', $repoPairs, $job->repo, "class='form-control'"); ?></td>
</tr>
<tr class='gitlabRepo hide'>
<th><?php echo $lang->job->repo; ?></th>
<td><?php echo html::select('gitlabRepo', $gitlabRepos, $job->repo, "class='form-control'"); ?></td>
</tr>
<tr>
<th><?php echo $lang->job->product;?></th>
@@ -166,7 +169,7 @@
<th></th>
<td colspan="2" class='text-center form-actions'>
<?php echo html::submitButton();?>
<?php echo html::backButton();?>
<?php if(!isonlybody()) echo html::a(inlink('browse', ""), $lang->goback, '', 'class="btn btn-wide"');?>
<?php echo html::hidden('repoType', zget($repoTypes, $job->repo, 'Git'));?>
</td>
</tr>
+1 -1
View File
@@ -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'");
+6
View File
@@ -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();