Skip to content

Commit

Permalink
BitBucket build improvements. (#776)
Browse files Browse the repository at this point in the history
* Make bitbucket build text a little clearer.

* Use "Test" if test task type.

* Print a visible log about bitbucket build status.

* Make URLs clickable in "command" logs type output.
  • Loading branch information
jonpugh authored Oct 26, 2023
1 parent a9f229c commit b051a6d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,43 @@ function devshop_bitbucket_hosting_task_update_status($task, $status) {
]), 'debug');

$t = [
'@env' => "{$task->ref->hosting_group}.{$task->ref->hosting_environment}"
'@action' => $task->task_type == 'install'? t('Install'):
($task->task_type == 'test'? t('Test'):
(!empty($task->task_args['test'])? t('Test'): t('Deploy'))),
'@env' => $task->ref->hosting_environment,
];

if ($status == HOSTING_TASK_PROCESSING) {
$params->state = $state = 'INPROGRESS';
$params->name = t('DevShop Deploy to @env: In Progress', $t);
$params->name = t('@action started: @env', $t);
}
elseif ($status == HOSTING_TASK_SUCCESS || $status == HOSTING_TASK_WARNING) {
$params->state = $state = 'SUCCESSFUL';
if ($status == HOSTING_TASK_SUCCESS) {
$params->name = t('DevShop Deploy to @env: Success', $t);
$params->name = t('@action Success: @env', $t);
}
else {
$params->name = t('DevShop Deploy to @env: Success (with warnings)', $t);
$params->name = t('@action Success (with warnings): @env', $t);
}
}
else {
$params->state = $state = 'FAILED';
$params->name = t('DevShop Deploy to @env: Failed', $t);
$params->name = t('@action Failed: @env', $t);
}

$params->key = "deploy.{$task->ref->hosting_group}.{$task->ref->hosting_environment}";
$params->url = $task->ref->url;
$params->description = url("node/$task->nid", ['absolute' => true]);
$params->url = url("node/$task->nid", ['absolute' => true]);
$params->description = $task->ref->url;

$build_status = $client->repositories()->workspaces($environment->bitbucket_owner)->commit($environment->bitbucket_repo)->statuses($sha)->build()->create((array) $params);

if (!empty($build_status)) {
drush_log("Build status: " . print_r($build_status,1), 'debug');
drush_log(t("Posted @state build status to BitBucket for commit @commit @url", [
'@state' => $build_status['state'],
'@commit' => $build_status['commit']['hash'],
'@url' => $build_status['commit']['links']['html']['href'],
]), 'p_log');
}

} catch (\Exception $e) {
Expand Down
7 changes: 7 additions & 0 deletions devmaster/modules/devshop/devshop_projects/inc/theme.inc
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,13 @@ function devshop_task_get_messages($task_node) {
}

if (!empty($command)) {

// Make URLs clickable:
$filter = new stdClass();
$filter->settings = [
'filter_url_length' => 1000,
];
$command = _filter_url($command, $filter);
$header = "<div class='panel-heading'><i class='fa fa-$icon pull-left'></i> $command</div>";
}
else {
Expand Down

0 comments on commit b051a6d

Please sign in to comment.