/** * Deletes a local dir used to manage a remote SCM repository. This is * tipically used for resetting the sources of a project (good for * when the user changes SCM settings). * * @param string $local */ public static function delete($local) { $ret = false; if (!empty($local)) { $ret = Framework_Filesystem::removeDir($local); } #if DEBUG if ($ret) { SystemEvent::raise(SystemEvent::DEBUG, "Deleted local working copy. [DIR={$local}]", __METHOD__); } else { SystemEvent::raise(SystemEvent::DEBUG, "Could not delete local working copy. [DIR={$local}]", __METHOD__); } #endif return $ret; }
public function resetScmConnector() { if (!Framework_Filesystem::removeDir($this->getScmLocalWorkingCopy()) && file_exists($this->getScmLocalWorkingCopy())) { SystemEvent::raise(SystemEvent::ERROR, "Could not remove existing sources working copy. [PID={$this->getId()}]", __METHOD__); return false; } if (!@mkdir($this->getScmLocalWorkingCopy(), DEFAULT_DIR_MASK, true)) { SystemEvent::raise(SystemEvent::ERROR, "Could not recreate sources dir for project. [PID={$this->getId()}]", __METHOD__); return false; } SystemEvent::raise(SystemEvent::INFO, "Project sources dir reset. [PID={$this->getId()}]", __METHOD__); $this->setStatus(self::STATUS_UNINITIALIZED); return true; }
public function generateReleasePackage() { $ret = false; if ($this->getStatus() != self::STATUS_FAIL) { $project = $this->getPtrProject(); // Easier handling $filename = "{$project->getReleasesDir()}{$project->getReleaseLabel()}-{$this->getId()}"; // // Rename the sources dir to the new dir that will be archived // $releaseDirName = "{$project->getReleaseLabel()}-{$this->getId()}"; $releaseDirPath = "{$project->getTempDir()}{$releaseDirName}"; if (!@rename($project->getSourcesDir(), $releaseDirPath)) { SystemEvent::raise(SystemEvent::ERROR, "Problems creating release dir. [BUILD={$this->getId()}] [PID={$project->getId()}]", __METHOD__); return false; } // // TODO: For now only tar is available. As soon as more are implemented, // it is required that Project keeps it's preferred archiver, so // that it can be fetched here and fed into getCmdForPackageGeneration() // $params = array('tmpDir' => $project->getTempDir(), 'archiverExecutable' => SystemSettings::EXECUTABLE_TAR, 'releaseLabel' => $filename, 'sourcesDir' => $releaseDirName); $command = $GLOBALS['settings']->getCmdForPackageGeneration($params); $command = str_replace('\\', '/', $command); $command = str_replace('//', '/', $command); if (preg_match("/({$project->getReleaseLabel()}-{$this->getId()}[.\\w]+) /", $command, $matches)) { $filename = $matches[1]; // Get the filename extension } $proc = new Framework_Process(); $proc->setExecutable($command, false); $proc->run(); if ($proc->getReturnValue() == 0) { $this->setReleaseFile($filename); $this->setStatus(self::STATUS_OK_WITH_PACKAGE); $ret = true; SystemEvent::raise(SystemEvent::DEBUG, "Generated release package for build. [BUILD={$this->getId()}] [PID={$project->getId()}] [COMMAND={$command}]", __METHOD__); } else { SystemEvent::raise(SystemEvent::ERROR, "Problems generating release package for build. [BUILD={$this->getId()}] [PID={$project->getId()}] [COMMAND={$command}]", __METHOD__); } // Remove the release dir Framework_Filesystem::removeDir($releaseDirPath); } return $ret; }