示例#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());
 }
示例#2
0
 /**
  * Returns a {@link Pipeline} object that is linked to this environment, but isn't saved into the database. This
  * shouldn't be saved into the database unless you plan on starting an actual pipeline.
  *
  * @return Pipeline
  */
 public function GenericPipeline()
 {
     $pipeline = Pipeline::create();
     $pipeline->EnvironmentID = $this->ID;
     return $pipeline;
 }