/** * [exportPackageToCache 导出包到缓存] * @return [type] [description] */ public function exportPackageToCache() { $this->log->info("START FUNCTION " . __FUNCTION__); $data = Flight::request()->query->getData(); $this->log->info('data:' . json_encode($data)); $needPara = array('product', 'name', 'version'); $optionalPara = array(); $this->checkParameter($needPara, $data, $optionalPara); extract($data); $errorArray = array('error' => ''); $packageItem = new Package(); $packageInfo = $packageItem->getInfo($product, $name, $version); if (empty($packageInfo)) { $errorArray['error'] = '指定的包不存在'; Flight::json($errorArray, 404); } $svnVersion = $packageInfo['svnVersion']; $svnPath = $packageInfo['path']; //开始导出到缓存 //使用php脚本 $shellRun = new PkgSvn(); $shellRunRes = $shellRun->exportPkg($svnPath, $svnVersion, $version, $packageInfo['frameworkType']); $this->log->info('shell run result:' . json_encode($shellRunRes)); $shellRunCode = $shellRunRes['code']; if ($shellRunCode != 0) { $errorArray['error'] = '导出包失败:' . $shellRunRes['msg']; Flight::json($errorArray, 400); } $exportPath = $shellRunRes['data']['exportPath']; $errorArray['exportPath'] = $exportPath; Flight::json($errorArray, 200); }
/** * [exportPackage 导出包] * @return [type] [description] */ public function exportPackage() { $this->log->info("START FUNCTION " . __FUNCTION__); $errorArray = array('error' => ''); // get $data = Flight::request()->query->getData(); //参数检查 $needPara = array('product', 'name', 'version'); $optionalPara = array(); $error = $this->checkParameter($needPara, $data, $optionalPara); $product = $data['product']; $name = $data['name']; $version = $data['version']; $this->log->info("{$product} {$name} {$version}"); $packageItem = new Package(); $packageInfo = $packageItem->getInfo($product, $name, $version); if ($packageInfo == null) { $errorArray['error'] = "package not exists {$product} {$name} {$version}"; $this->log->info("{$errorArray['error']}"); Flight::json($errorArray, 404); } $svnPath = $packageInfo['path']; $svnVersion = $packageInfo['svnVersion']; if (empty($svnPath)) { $svnPath = "/{$product}/{$name}"; } $frameworkType = $packageInfo['frameworkType']; $copyPath = "/"; $shellRun = new PkgSvn(); $shellRunRes = $shellRun->exportPkg($svnPath, $svnVersion, $version, $frameworkType); $this->log->info('shell run result:' . json_encode($shellRunRes)); $shellRunCode = $shellRunRes['code']; if ($shellRunCode != 0) { $errorArray['error'] = "导出包失败:" . $shellRunRes['msg']; $this->log->info("{$errorArray['error']}"); Flight::json($errorArray, 400); } //成功 $this->log->info("export done"); Flight::json($errorArray, 200); }