示例#1
0
 /**
  * @param Process $process
  * @return callable
  */
 public function updateRelease(Process $process)
 {
     $out = $process->getIncrementalOutput() . $process->getIncrementalErrorOutput();
     $this->release->update(['raw_log' => $process->getOutput() . PHP_EOL . $process->getErrorOutput()]);
     if (!empty($out)) {
         $this->release->logger()->info($out);
     }
 }
示例#2
0
 public function fire(Dispatcher $bus)
 {
     $repo = $this->loadRepo();
     $inv = $this->loadInventory($repo);
     $commit = $this->getCommit($repo);
     $release = Release::create(['repo_id' => $repo->id, 'commit' => $commit->getHash(), 'status' => Release::QUEUED, 'roles' => ["dogpro.deploy"], 'inventory_id' => $inv->id, 'user_id' => 1, 'params' => []]);
     $this->output->getFormatter()->setDecorated(true);
     $release->logger()->setOutput($this->output);
     try {
         $bus->dispatchNow(new PrepareReleaseJob($release, true));
     } catch (\Exception $e) {
         $this->output->writeln($e->getMessage());
     }
 }
示例#3
0
 public function checkCommitsForDeployTags()
 {
     $inv = null;
     $commit = null;
     foreach ($this->commitList as $commit) {
         $parts = explode(" ", $commit['message']);
         if (($index = array_search('@deploy', $parts)) !== false) {
             if (isset($parts[$index + 1])) {
                 $inv = $this->repo->inventories()->where('name', trim($parts[$index + 1]))->get()->first();
                 if ($inv) {
                     break;
                 }
             }
         }
     }
     if ($inv instanceof Inventory && !empty($commit['hash'])) {
         $this->dispatch(new PrepareReleaseJob(Release::create(['repo_id' => $this->repo->id, 'commit' => $commit['hash'], 'status' => Release::QUEUED, 'roles' => ['dogpro.deploy'], 'inventory_id' => $inv->id])));
     }
 }
示例#4
0
 /**
  * @throws \App\Exceptions\InvalidConfigException
  * @throws ReleaseException
  */
 private function writePlaybooks()
 {
     $this->fs()->put($this->release->path("empty.yml"), "");
     $playbook = new PlaybookConfig();
     $config = $this->release->config();
     foreach ($config->roles() as $play) {
         if (in_array($play->name(), $this->release->roles) || in_array($play->role(), $this->release->roles)) {
             $play->setSudo(true);
             $playbook->add($play);
         }
     }
     $playbook->setVars(["project_name" => $this->release->repo->name, "global" => array_merge($config->defaults(), $config->globals(), (array) $this->release->repo->params), "build_tar" => $this->release->path("build.tar.gz"), "build_path" => $this->release->path(), "build_version" => $this->release->commit, "build_version_short" => $this->release->commit()->getShortHash(), "inventory_name" => $this->release->inventory->name] + $config->getVars());
     $playbookFile = $this->release->path(Release::PLAYBOOK_FILENAME);
     if (!$this->fs()->put($playbookFile, $playbook->render())) {
         throw new ReleaseException($this->release, "Cannot write playbook file: {$playbookFile}!");
     }
     $inventoryFile = $this->release->path(Release::INVENTORY_FILENAME);
     if (!$this->fs()->put($inventoryFile, $this->release->inventory->render())) {
         throw new ReleaseException($this->release, "Cannot write inventory file: {$inventoryFile}!");
     }
 }
示例#5
0
 /**
  * @param Process $process
  * @return callable
  */
 public function updateRelease(Process $process)
 {
     $this->release->update(['raw_log' => $process->getOutput() . PHP_EOL . $process->getErrorOutput()]);
 }
示例#6
0
 /**
  * @param Release $release
  * @param $commit
  * @return array
  */
 protected function describeCommitFields(Release $release, Commit $commit)
 {
     return [['title' => 'Commit', 'value' => $commit->getShortHash(), 'short' => true], ['title' => 'Message', 'value' => $commit->getShortMessage(), 'short' => true], ['title' => 'Author', 'value' => $commit->getAuthorName() . '(' . $commit->getAuthorEmail() . ')'], ['title' => 'Details', 'value' => $release->url()]];
 }
示例#7
0
 public function get(Release $release)
 {
     return $release->toArray() + ['time_avg' => $release->avg()];
 }
示例#8
0
 protected function pushRelease(array $data = [])
 {
     $this->pusher->trigger(['releases'], "release-" . $this->release->id, $this->release->toArray() + $data);
 }
示例#9
0
 /**
  * @param Release $release
  * @return array
  */
 public function get(Release $release)
 {
     return $release->load('inventory');
 }