/** * Deploy the given build to the given environment */ public function deploy($environment, $sha, DeploynautLogFile $log, DNProject $project) { GraphiteDeploymentNotifier::notify_start($environment, $sha, null, $project); $file = DEPLOYNAUT_LOG_PATH . '/' . $project->Name . ':' . $environment . ".deploy-history.txt"; $CLI_file = escapeshellarg($file); $CLI_line = escapeshellarg(date('Y-m-d H:i:s') . " => {$sha}"); $log->write("Demo deployment: echo {$CLI_line} >> {$CLI_file}"); `echo {$CLI_line} >> {$CLI_file}`; $log->write("Arbitrary pause for 10s"); sleep(10); $log->write("Well, that was a waste of time"); GraphiteDeploymentNotifier::notify_end($environment, $sha, null, $project); }
/** * Deploy the given build to the given environment. */ public function deploy($environment, $sha, DeploynautLogFile $log, DNProject $project) { $repository = $project->LocalCVSPath; $projectName = $project->Name; $env = $project->getProcessEnv(); $project = DNProject::get()->filter('Name', $projectName)->first(); GraphiteDeploymentNotifier::notify_start($environment, $sha, null, $project); $log->write('Deploying "' . $sha . '" to "' . $projectName . ':' . $environment . '"'); $this->enableMaintenance($environment, $log, $project); $args = array('branch' => $sha, 'repository' => $repository); $command = $this->getCommand('deploy', $projectName . ':' . $environment, $args, $env, $log); $command->run(function ($type, $buffer) use($log) { $log->write($buffer); }); if (!$command->isSuccessful()) { // disable the maintenance page in the event of a failure $this->disableMaintenance($environment, $log, $project); throw new RuntimeException($command->getErrorOutput()); } $this->disableMaintenance($environment, $log, $project); $log->write('Deploy done "' . $sha . '" to "' . $projectName . ':' . $environment . '"'); GraphiteDeploymentNotifier::notify_end($environment, $sha, null, $project); }