* finish task #6939.

This commit is contained in:
wangyidong
2020-03-04 18:21:46 +08:00
parent a6169ffec5
commit 718373cc06
10 changed files with 229 additions and 295 deletions
+42 -42
View File
@@ -44,6 +44,48 @@ class jenkinsModel extends model
->fetchAll('id');
}
/**
* Get jenkins pairs
*
* @return array
*/
public function getPairs()
{
$jenkins = $this->dao->select('id,name')->from(TABLE_JENKINS)->where('deleted')->eq('0')->orderBy('id')->fetchPairs('id', 'name');
$jenkins = array('' => '') + $jenkins;
return $jenkins;
}
/**
* Get jenkins tasks.
*
* @param int $id
* @access public
* @return array
*/
public function getTasks($id)
{
$jenkins = $this->getById($id);
$jenkinsServer = $jenkins->url;
$jenkinsUser = $jenkins->account;
$jenkinsPassword = $jenkins->token ? $jenkins->token : $jenkins->password;
$jenkinsAuth = '://' . $jenkinsUser . ':' . $jenkinsPassword . '@';
$jenkinsServer = str_replace('://', $jenkinsAuth, $jenkinsServer);
$response = common::http($jenkinsServer . '/api/json/items/list');
$response = json_decode($response);
$tasks = array();
if(isset($response->jobs))
{
foreach($response->jobs as $job) $tasks[basename($job->url)] = $job->name;
}
return $tasks;
}
/**
* Create a jenkins.
*
@@ -93,46 +135,4 @@ class jenkinsModel extends model
->exec();
return !dao::isError();
}
/**
* list jenkins for ci task edit
*
* @return array
*/
public function getPairs()
{
$jenkins = $this->dao->select('id,name')->from(TABLE_JENKINS)->where('deleted')->eq('0')->orderBy('id')->fetchPairs('id', 'name');
$jenkins = array('' => '') + $jenkins;
return $jenkins;
}
/**
* Get jenkins tasks.
*
* @param int $id
* @access public
* @return array
*/
public function getTasks($id)
{
$jenkins = $this->getById($id);
$jenkinsServer = $jenkins->url;
$jenkinsUser = $jenkins->account;
$jenkinsPassword = $jenkins->token ? $jenkins->token : $jenkins->password;
$jenkinsAuth = '://' . $jenkinsUser . ':' . $jenkinsPassword . '@';
$jenkinsServer = str_replace('://', $jenkinsAuth, $jenkinsServer);
$response = common::http($jenkinsServer . '/api/json/items/list');
$response = json_decode($response);
$tasks = array();
if(isset($response->jobs))
{
foreach($response->jobs as $job) $tasks[basename($job->url)] = $job->name;
}
return $tasks;
}
}