Наследование: extends Illuminate\Database\Eloquent\Model, implements Robbo\Presenter\PresentableInterface, implements REBELinBLUE\Deployer\Contracts\RuntimeInterface, use trait Illuminate\Database\Eloquent\SoftDeletes
 /**
  * Execute the command.
  */
 public function handle()
 {
     $emails = $this->project->notifyEmails;
     if ($emails->count() > 0) {
         $status = strtolower($this->project->getPresenter()->readable_status);
         $subject = Lang::get('notifyEmails.subject', ['status' => $status, 'project' => $this->project->name]);
         $deploymentArr = $this->deployment->toArray();
         $deploymentArr['commitURL'] = $this->deployment->commit_url;
         $deploymentArr['shortCommit'] = $this->deployment->short_commit;
         $data = ['project' => $this->project->toArray(), 'deployment' => $deploymentArr];
         Mail::queueOn('deployer-low', 'emails.deployed', $data, function (Message $message) use($emails, $subject) {
             foreach ($emails as $email) {
                 $message->to($email->email, $email->name);
             }
             $message->subject($subject);
         });
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('deployments', function (Blueprint $table) {
         $table->string('branch')->default('master');
     });
     foreach (Deployment::all() as $deployment) {
         $deployment->branch = $deployment->project->branch;
         $deployment->save();
     }
 }
 /**
  * Cleans up any stalled deployments in the database.
  *
  * @tpdp Maybe readd pending to the queue if possible?
  * @return void
  */
 public function cleanupDeployments()
 {
     // Mark any pending steps as cancelled
     ServerLog::where('status', '=', ServerLog::PENDING)->update(['status' => ServerLog::CANCELLED]);
     // Mark any running steps as failed
     ServerLog::where('status', '=', ServerLog::RUNNING)->update(['status' => ServerLog::FAILED]);
     // Mark any running/pending deployments as failed
     Deployment::whereIn('status', [Deployment::DEPLOYING, Deployment::PENDING])->update(['status' => Deployment::FAILED]);
     // Mark any deploying/pending projects as failed
     Project::whereIn('status', [Project::DEPLOYING, Project::PENDING])->update(['status' => Project::FAILED]);
 }
Пример #4
0
 /**
  * Sets the deployment to pending.
  */
 private function setDeploymentStatus()
 {
     $this->deployment->status = Deployment::PENDING;
     $this->deployment->started_at = date('Y-m-d H:i:s');
     $this->deployment->project_id = $this->project->id;
     if (Auth::check()) {
         $this->deployment->user_id = Auth::user()->id;
     } else {
         $this->deployment->is_webhook = true;
     }
     $this->deployment->committer = $this->deployment->committer ?: Deployment::LOADING;
     $this->deployment->commit = $this->deployment->commit ?: Deployment::LOADING;
     $this->deployment->save();
     $this->deployment->project->status = Project::PENDING;
     $this->deployment->project->save();
 }
Пример #5
0
 /**
  * Clones the repository locally to get the latest log entry and updates
  * the deployment model.
  */
 private function updateRepoInfo()
 {
     $commit = $this->deployment->commit === Deployment::LOADING ? null : $this->deployment->commit;
     $process = new Process('tools.GetCommitDetails', ['mirror_path' => $this->deployment->project->mirrorPath(), 'git_reference' => $commit ?: $this->deployment->branch]);
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException('Could not get repository info - ' . $process->getErrorOutput());
     }
     $git_info = $process->getOutput();
     list($commit, $committer, $email) = explode("\t", $git_info);
     $this->deployment->commit = $commit;
     $this->deployment->committer = trim($committer);
     $this->deployment->committer_email = trim($email);
     if (!$this->deployment->user_id && !$this->deployment->source) {
         $user = User::where('email', $this->deployment->committer_email)->first();
         if ($user) {
             $this->deployment->user_id = $user->id;
         }
     }
     $this->deployment->save();
 }
Пример #6
0
 /**
  * Checks if there are any running or pending deployments.
  *
  * @return bool
  */
 protected function hasRunningDeployments()
 {
     $deploys = Deployment::whereIn('status', [Deployment::DEPLOYING, Deployment::PENDING])->count();
     if ($deploys > 0) {
         $this->block(['Deployments in progress', PHP_EOL, 'There are still running deployments, please wait for them to finish before updating.']);
         return true;
     }
     return false;
 }