/**
* Start a resque job for this deployment
*
* @return string Resque token
*/
protected function enqueueDeployment()
{
$environment = $this->Environment();
$project = $environment->Project();
$log = $this->log();
$args = array('environmentName' => $environment->Name, 'repository' => $project->getLocalCVSPath(), 'logfile' => $this->logfile(), 'projectName' => $project->Name, 'env' => $project->getProcessEnv(), 'deploymentID' => $this->ID);
$strategy = new DeploymentStrategy($environment);
$strategy->fromJSON($this->Strategy);
// Inject options.
$args = array_merge($args, $strategy->getOptions());
// Make sure we use the SHA as it was written into this DNDeployment.
$args['sha'] = $this->SHA;
if (!$this->DeployerID) {
$this->DeployerID = Member::currentUserID();
}
if ($this->DeployerID) {
$deployer = $this->Deployer();
$message = sprintf('Deploy to %s initiated by %s (%s), with IP address %s', $environment->getFullName(), $deployer->getName(), $deployer->Email, Controller::curr()->getRequest()->getIP());
$log->write($message);
}
return Resque::enqueue('deploy', 'DeployJob', $args, true);
}