Dear people of the future: If you are looking to optimize this, simply create a CurrentBuildSHA(), which can be
a lot faster. I presume you came here because of the Project display template, which only needs a SHA.
public CurrentBuild ( ) : false | DNDeployment | ||
리턴 | false | DNDeployment |
/** * @param \SS_HTTPRequest $request * @return \SS_HTTPResponse */ public function redeploy(\SS_HTTPRequest $request) { $currentBuild = $this->environment->CurrentBuild(); if (!$currentBuild || !$currentBuild->exists()) { return $this->redirect(Controller::join_links($this->environment->Link(\EnvironmentOverview::ACTION_OVERVIEW), 'deployment', 'new')); } $strategy = $this->environment->Backend()->planDeploy($this->environment, ['sha' => $currentBuild->SHA, 'ref_type' => \GitDispatcher::REF_TYPE_PREVIOUS, 'ref_name' => $currentBuild->RefName]); $deployment = $strategy->createDeployment(); return $this->redirect($deployment->Link()); }
/** * Create a deployment strategy. * * @param DNEnvironment $environment * @param array $options * * @return DeploymentStrategy */ public function planDeploy(DNEnvironment $environment, $options) { $strategy = new DeploymentStrategy($environment, $options); $currentBuild = $environment->CurrentBuild(); $currentSha = $currentBuild ? $currentBuild->SHA : '-'; if ($currentSha !== $options['sha']) { $strategy->setChange('Code version', $currentSha, $options['sha']); } $strategy->setActionTitle('Confirm deployment'); $strategy->setActionCode('fast'); $strategy->setEstimatedTime('2'); return $strategy; }