Skip to content

Commit fb50e6d

Browse files
Cawlleckattrali
authored andcommitted
Update deploy command to new build API (#279)
1 parent 313002c commit fb50e6d

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

config/bugsnag.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,4 +263,16 @@
263263
*/
264264

265265
'session_endpoint' => env('BUGSNAG_SESSION_ENDPOINT'),
266+
267+
/*
268+
|--------------------------------------------------------------------------
269+
| Builds Endpoint
270+
|--------------------------------------------------------------------------
271+
|
272+
| Sets a url to send build reports to.
273+
|
274+
*/
275+
276+
'build_endpoint' => env('BUGSNAG_BUILD_ENDPOINT'),
277+
266278
];

example/laravel/app/Console/Kernel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Kernel extends ConsoleKernel
1414
*/
1515
protected $commands = [
1616
// Commands\Inspire::class,
17+
\Bugsnag\BugsnagLaravel\Commands\DeployCommand::class
1718
];
1819

1920
/**

src/BugsnagServiceProvider.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ public function register()
208208
$this->setupSessionTracking($client, $endpoint, $this->app->events);
209209
}
210210

211+
if (isset($config['build_endpoint'])) {
212+
$client->setBuildEndpoint($config['build_endpoint']);
213+
}
214+
211215
return $client;
212216
});
213217

src/Commands/DeployCommand.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
namespace Bugsnag\BugsnagLaravel\Commands;
44

5+
use Bugsnag\Bugsnag\Utils;
56
use Bugsnag\BugsnagLaravel\Facades\Bugsnag;
67
use Illuminate\Console\Command;
78
use Symfony\Component\Console\Input\InputOption;
9+
use Symfony\Component\Process\Process;
810

911
class DeployCommand extends Command
1012
{
@@ -20,7 +22,7 @@ class DeployCommand extends Command
2022
*
2123
* @var string
2224
*/
23-
protected $description = 'Notifies Bugsnag of a deployment';
25+
protected $description = 'Notifies Bugsnag of a build';
2426

2527
/**
2628
* Execute the console command.
@@ -29,9 +31,21 @@ class DeployCommand extends Command
2931
*/
3032
public function handle()
3133
{
32-
Bugsnag::deploy($this->option('repository'), $this->option('branch'), $this->option('revision'));
34+
$builderName = $this->option('builder');
35+
if (is_null($builderName)) {
36+
if (class_exists(Process::class)) {
37+
$process = new Process('whoami');
38+
$process->run();
39+
if ($process->isSuccessful()) {
40+
$builderName = trim($process->getOutput());
41+
}
42+
} else {
43+
$builderName = Utils::getBuilderName();
44+
}
45+
}
46+
Bugsnag::build($this->option('repository'), $this->option('revision'), $this->option('provider'), $builderName);
3347

34-
$this->info('Notified Bugsnag of the deploy!');
48+
$this->info('Notified Bugsnag of the build!');
3549
}
3650

3751
/**
@@ -53,8 +67,10 @@ protected function getOptions()
5367
{
5468
return [
5569
['repository', null, InputOption::VALUE_OPTIONAL, 'The repository from which you are deploying the code.', null],
56-
['branch', null, InputOption::VALUE_OPTIONAL, 'The source control branch from which you are deploying.', null],
70+
['branch', null, InputOption::VALUE_OPTIONAL, 'The source control branch from which you are deploying. Deprecated.', null],
5771
['revision', null, InputOption::VALUE_OPTIONAL, 'The source control revision you are currently deploying.', null],
72+
['provider', null, InputOption::VALUE_OPTIONAL, 'The provider of your source control repository.', null],
73+
['builder', null, InputOption::VALUE_OPTIONAL, 'The machine or person who has executed the build', null],
5874
];
5975
}
6076
}

0 commit comments

Comments
 (0)