Get the build selected from the given data
public getSelectedBuild ( array $data ) : string | ||
$data | array | |
Результат | string | SHA of selected build |
/** * Start a pipeline * * @param array $data * @param DeployForm $form * @param bool $isDryRun * @return \SS_HTTPResponse */ protected function beginPipeline($data, DeployForm $form, $isDryRun = false) { $buildName = $form->getSelectedBuild($data); // Performs canView permission check by limiting visible projects $project = $this->getCurrentProject(); if (!$project) { return $this->project404Response(); } // Performs canView permission check by limiting visible projects $environment = $this->getCurrentEnvironment($project); if (!$environment) { return $this->environment404Response(); } if (!$environment->DryRunEnabled && $isDryRun) { return new SS_HTTPResponse("Dry-run for pipelines is not enabled for this environment", 404); } // Initiate the pipeline $sha = $project->DNBuildList()->byName($buildName); $pipeline = Pipeline::create(); $pipeline->DryRun = $isDryRun; $pipeline->EnvironmentID = $environment->ID; $pipeline->AuthorID = Member::currentUserID(); $pipeline->SHA = $sha->FullName(); // Record build at time of execution if ($currentBuild = $environment->CurrentBuild()) { $pipeline->PreviousDeploymentID = $currentBuild->ID; } $pipeline->start(); // start() will call write(), so no need to do it here as well. return $this->redirect($environment->Link()); }
/** * Deployment form submission handler. * * Initiate a DNDeployment record and redirect to it for status polling * * @param array $data * @param DeployForm $form * @return \SS_HTTPResponse */ public function doDeploy($data, $form) { $buildName = $form->getSelectedBuild($data); // Performs canView permission check by limiting visible projects $project = $this->getCurrentProject(); if (!$project) { return new SS_HTTPResponse("Project '" . Convert::raw2xml($this->getRequest()->latestParam('Project')) . "' not found.", 404); } // Performs canView permission check by limiting visible projects $environment = $this->getCurrentEnvironment($project); if (!$environment) { return new SS_HTTPResponse("Environment '" . Convert::raw2xml($this->getRequest()->latestParam('Environment')) . "' not found.", 404); } // Initiate the deployment // The extension point should pass in: Project, Environment, SelectRelease, buildName $this->extend('doDeploy', $project, $environment, $buildName, $data); $sha = $project->DNBuildList()->byName($buildName); $deployment = DNDeployment::create(); $deployment->EnvironmentID = $environment->ID; $deployment->SHA = $sha->FullName(); $deployment->write(); $deployment->start(); return $this->redirect($deployment->Link()); }