private function BitbucketFrontendEnvironment::getLastBitbucketDeploymentsTable in Build Hooks 3.x
Same name and namespace in other branches
- 8.2 modules/build_hooks_bitbucket/src/Plugin/FrontendEnvironment/BitbucketFrontendEnvironment.php \Drupal\build_hooks_bitbucket\Plugin\FrontendEnvironment\BitbucketFrontendEnvironment::getLastBitbucketDeploymentsTable()
Gets info about the latest bitbucket deployments for this environment.
Parameters
array $settings: The plugin settings array.
Return value
array Render array.
Throws
\GuzzleHttp\Exception\GuzzleException When fetching fails.
1 call to BitbucketFrontendEnvironment::getLastBitbucketDeploymentsTable()
- BitbucketFrontendEnvironment::getAdditionalDeployFormElements in modules/
build_hooks_bitbucket/ src/ Plugin/ FrontendEnvironment/ BitbucketFrontendEnvironment.php - Allows the plugin to add elements to the deployment form.
File
- modules/
build_hooks_bitbucket/ src/ Plugin/ FrontendEnvironment/ BitbucketFrontendEnvironment.php, line 207
Class
- BitbucketFrontendEnvironment
- Provides a 'Bitbucket pipelines' frontend environment type.
Namespace
Drupal\build_hooks_bitbucket\Plugin\FrontendEnvironmentCode
private function getLastBitbucketDeploymentsTable(array $settings) {
$latest_builds = $this->bitbucketManager
->retrieveLatestBuilds($settings, 15);
$element = [
'#type' => 'table',
'#attributes' => [
'id' => 'ajax-replace-table',
],
'#header' => [
$this
->t('Build'),
$this
->t('Status'),
$this
->t('Started at'),
$this
->t('Finished at'),
],
];
if (!empty($latest_builds)) {
foreach ($latest_builds['values'] as $pipeline_id => $pipeline_data) {
$element[$pipeline_id]['build'] = [
'#type' => 'link',
'#url' => Url::fromUri($pipeline_data['repository']['links']['html']['href'] . '/addon/pipelines/home', [
'fragment' => '!/results/' . $pipeline_data['build_number'],
]),
'#title' => 'Build ' . $pipeline_data['build_number'],
'#attributes' => [
'target' => '_blank',
],
];
$pipeline_name = $pipeline_data['state']['name'];
$pipeline_name .= isset($pipeline_data['state']['result']) ? ' - ' . $pipeline_data['state']['result']['name'] : '';
$element[$pipeline_id]['name'] = [
'#plain_text' => $pipeline_name,
];
$element[$pipeline_id]['started_at'] = [
'#type' => 'item',
'#markup' => !empty($pipeline_data['created_on']) ? $this->bitbucketManager
->formatBitbucketDateTime($pipeline_data['created_on']) : '',
];
$element[$pipeline_id]['completed_on'] = [
'#type' => 'item',
'#markup' => !empty($pipeline_data['completed_on']) ? $this->bitbucketManager
->formatBitbucketDateTime($pipeline_data['completed_on']) : '',
];
}
}
return $element;
}