DeployForm::getSelectedBuild PHP Method

getSelectedBuild() public method

Get the build selected from the given data
public getSelectedBuild ( array $data ) : string
$data array
return string SHA of selected build
    public function getSelectedBuild($data)
    {
        if (isset($data['SelectRelease']) && !empty($data[$data['SelectRelease']])) {
            // Filter out the tag/branch name if required
            $array = explode('-', $data[$data['SelectRelease']]);
            return reset($array);
        }
        if (isset($data['FilteredCommits']) && !empty($data['FilteredCommits'])) {
            return $data['FilteredCommits'];
        }
    }

Usage Example

Example #1
0
 /**
  * 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());
 }
All Usage Examples Of DeployForm::getSelectedBuild