Merge branch '18.4' of https://git.zcorp.cc/easycorp/zentaopms into 18.4
This commit is contained in:
@@ -134,13 +134,18 @@ class compileModel extends model
|
||||
|
||||
$url = new stdclass();
|
||||
$url->userPWD = "$jenkinsUser:$jenkinsPassword";
|
||||
|
||||
$detailUrl = strpos($jenkins->pipeline, '/job/') !== false ? sprintf('%s%s/api/json', $jenkinsServer, $jenkins->pipeline) : sprintf('%s/job/%s/api/json', $jenkinsServer, $jenkins->pipeline);
|
||||
$hasParameterizedBuild = $this->loadModel('job')->checkParameterizedBuild($detailUrl, $url->userPWD);
|
||||
$buildInterface = $hasParameterizedBuild ? 'buildWithParameters' : 'build';
|
||||
|
||||
if(strpos($jenkins->pipeline, '/job/') !== false)
|
||||
{
|
||||
$url->url = sprintf('%s%sbuildWithParameters/api/json', $jenkinsServer, $jenkins->pipeline);
|
||||
$url->url = sprintf("%s%s{$buildInterface}/api/json", $jenkinsServer, $jenkins->pipeline);
|
||||
}
|
||||
else
|
||||
{
|
||||
$url->url = sprintf('%s/job/%s/buildWithParameters/api/json', $jenkinsServer, $jenkins->pipeline);
|
||||
$url->url = sprintf("%s/job/%s/{$buildInterface}/api/json", $jenkinsServer, $jenkins->pipeline);
|
||||
}
|
||||
|
||||
return $url;
|
||||
|
||||
@@ -672,4 +672,19 @@ class jobModel extends model
|
||||
->beginIF(!empty($projectKeys) or !$emptyShowAll)->andWhere('projectKey')->in($projectKeys)->fi()
|
||||
->fetchPairs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if jenkins has enabled parameterized build.
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $userPWD
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function checkParameterizedBuild($url, $userPWD)
|
||||
{
|
||||
$response = common::http($url, null, array(CURLOPT_HEADER => true, CURLOPT_USERPWD => $userPWD));
|
||||
|
||||
return strpos($response, 'hudson.model.ParametersDefinitionProperty') !== false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user