22
33namespace Bugsnag \BugsnagLaravel \Commands ;
44
5+ use Bugsnag \Bugsnag \Utils ;
56use Bugsnag \BugsnagLaravel \Facades \Bugsnag ;
67use Illuminate \Console \Command ;
78use Symfony \Component \Console \Input \InputOption ;
9+ use Symfony \Component \Process \Process ;
810
911class 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