From e0929cd7b657a61cf874be7440e546e6f7071574 Mon Sep 17 00:00:00 2001 From: Stefan Graupner Date: Thu, 10 Sep 2015 00:55:09 +0200 Subject: [PATCH] Implemented versions:get --- app/Console/Commands/GetVersionCommand.php | 74 ++++++++++++---------- app/Jobs/CreateBuild.php | 19 ++---- 2 files changed, 47 insertions(+), 46 deletions(-) diff --git a/app/Console/Commands/GetVersionCommand.php b/app/Console/Commands/GetVersionCommand.php index 13c0b202..2553fb8a 100644 --- a/app/Console/Commands/GetVersionCommand.php +++ b/app/Console/Commands/GetVersionCommand.php @@ -2,41 +2,49 @@ namespace App\Console\Commands; +use App\Jobs\CreateBuild; use Illuminate\Console\Command; +use Illuminate\Foundation\Bus\DispatchesJobs; class GetVersionCommand extends Command { - /** - * The name and signature of the console command. - * - * @var string - */ - protected $signature = 'versions:get'; - - /** - * The console command description. - * - * @var string - */ - protected $description = 'Dispatches a job to Buildkite for compiling a specific version.'; - - /** - * Create a new command instance. - * - * @return void - */ - public function __construct() - { - parent::__construct(); - } - - /** - * Execute the console command. - * - * @return mixed - */ - public function handle() - { - // - } + use DispatchesJobs; + + /** + * The name and signature of the console command. + * + * @var string + */ + protected $signature = 'versions:get {hash}'; + + /** + * The console command description. + * + * @var string + */ + protected $description = 'Dispatches a job to Buildkite for compiling a specific version.'; + + /** + * Create a new command instance. + * + * @return void + */ + public function __construct() + { + parent::__construct(); + } + + /** + * Execute the console command. + * + * @return mixed + */ + public function handle() + { + $hash = $this->argument('hash'); + + $this->info("Scheduling build create job for {$hash}"); + + $this->dispatch(new CreateBuild($hash, '[Artisan]')); + } } diff --git a/app/Jobs/CreateBuild.php b/app/Jobs/CreateBuild.php index 07804eb1..639dad73 100644 --- a/app/Jobs/CreateBuild.php +++ b/app/Jobs/CreateBuild.php @@ -9,13 +9,7 @@ * Create Build Job * * This job is used to create spec builds on Buildkite - * on-demand. The code flow for on-demand builds as far as - * this job is concerned is: - * - * 1) User requests unavailable version - * 2) This job is being scheduled - * 3) This job calls the Buildkite API to execute the build - * 4) This job is done -> Processing continues at HooksController@addVersion + * on-demand. * * @package App\Jobs **/ @@ -27,20 +21,19 @@ class CreateBuild extends Job implements SelfHandling protected $hash = ''; /** - * @var string The requested format (required for info mail) + * @var string Meta information to be added to the build request message **/ - protected $format = ''; + protected $buildMeta = ''; /** * Create a new Build Job instance * * @param string $hash The requested version - * @param string $format The requested format (required for info mail) */ - public function __construct($hash, $format) + public function __construct($hash, $meta = '') { $this->hash = $hash; - $this->format = $format; + $this->buildMeta = ' '.$meta; } /** @@ -54,7 +47,7 @@ public function handle() { // create the build $build = new CreateBuildRequest( - "Building requested version {$this->hash}", + "Building requested version {$this->hash}{$this->buildMeta}", $this->hash );