public function BitbucketManager::retrieveLatestBuilds in Build Hooks 8.2
Same name and namespace in other branches
- 3.x modules/build_hooks_bitbucket/src/BitbucketManager.php \Drupal\build_hooks_bitbucket\BitbucketManager::retrieveLatestBuilds()
Get the latest builds from bitbucket pipelines.
Parameters
array $settings: The plugin settings array.
int $limit: Number of desired builds to retrieve.
Return value
array An array with info about the builds.
Throws
\GuzzleHttp\Exception\GuzzleException
File
- modules/
build_hooks_bitbucket/ src/ BitbucketManager.php, line 115
Class
- BitbucketManager
- Service for managing BitBucket connection details.
Namespace
Drupal\build_hooks_bitbucketCode
public function retrieveLatestBuilds(array $settings, $limit = 10) {
$url = $this
->getPipelinesApiPath($settings);
$url .= '?sort=' . urlencode('-created_on') . '&pagelen=' . (int) $limit;
if ($settings['ref']['type'] == 'branch') {
$url .= '&target.branch=' . urlencode($settings['ref']['name']);
}
elseif ($settings['ref']['type'] == 'tag') {
$url .= '&target.tag=' . urlencode($settings['ref']['name']);
}
$options = [
'auth' => $this
->getAuth(),
];
$response = $this->httpClient
->request('GET', $url, $options);
return json_decode($response
->getBody()
->getContents(), TRUE);
}