Skip to content

Commit

Permalink
Implemented versions:get
Browse files Browse the repository at this point in the history
  • Loading branch information
eFrane committed Sep 9, 2015
1 parent 8d8e535 commit e0929cd
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 46 deletions.
74 changes: 41 additions & 33 deletions app/Console/Commands/GetVersionCommand.php
Expand Up @@ -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]'));
}
}
19 changes: 6 additions & 13 deletions app/Jobs/CreateBuild.php
Expand Up @@ -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
**/
Expand All @@ -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;
}

/**
Expand All @@ -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
);

Expand Down

0 comments on commit e0929cd

Please sign in to comment.