本文整理匯總了PHP中app\models\Project::getTargetWorkspace方法的典型用法代碼示例。如果您正苦於以下問題:PHP Project::getTargetWorkspace方法的具體用法?PHP Project::getTargetWorkspace怎麽用?PHP Project::getTargetWorkspace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Project
的用法示例。
在下文中一共展示了Project::getTargetWorkspace方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getRemoteTaskCommand
/**
* 獲取遠程服務器要操作的任務命令
*
* @param $task string
* @param $version string
* @return string string
*/
public static function getRemoteTaskCommand($task, $version)
{
$tasks = GlobalHelper::str2arr($task);
if (empty($tasks)) {
return '';
}
$cmd = [];
$workspace = Project::getTargetWorkspace();
$version = Project::getReleaseVersionDir($version);
$pattern = ['#{WORKSPACE}#', '#{VERSION}#'];
$replace = [$workspace, $version];
foreach ($tasks as $task) {
$cmd[] = preg_replace($pattern, $replace, $task);
}
return join(' && ', $cmd);
}
示例2: _unpackageFilesByAnsible
/**
* @param Project $project
* @param TaskModel $task
* @return bool
* @throws \Exception
*/
protected function _unpackageFilesByAnsible(Project $project, TaskModel $task)
{
$version = $task->link_id;
$releasePackage = Project::getReleaseVersionPackage($version);
$webrootPath = Project::getTargetWorkspace();
$releasePath = Project::getReleaseVersionDir($version);
$cmd = [];
if ($task->file_transmission_mode == TaskModel::FILE_TRANSMISSION_MODE_PART) {
// 增量傳輸時, 在解壓數據包之前, 需要把目標機當前版本複製一份到release目錄
$cmd[] = sprintf('cp -arf %s/. %s', $webrootPath, $releasePath);
}
$cmd[] = sprintf('cd %1$s && tar --no-same-owner -pm -C %1$s -xz -f %2$s', $releasePath, $releasePackage);
$command = join(' && ', $cmd);
$ret = $this->runRemoteCommandByAnsibleShell($command);
if (!$ret) {
throw new \Exception(yii::t('walle', 'unpackage error'));
}
return true;
}
示例3: getRemoteTaskCommand
/**
* 獲取遠程服務器要操作的任務命令
*
* @param $task string
* @param $version string
* @return string string
*/
public static function getRemoteTaskCommand($task, $version)
{
$tasks = GlobalHelper::str2arr($task);
if (empty($tasks)) {
return '';
}
// 可能要做一些依賴環境變量的命令操作
$cmd = ['source /etc/profile'];
$workspace = Project::getTargetWorkspace();
$version = Project::getReleaseVersionDir($version);
$pattern = ['#{WORKSPACE}#', '#{VERSION}#'];
$replace = [$workspace, $version];
// 簡化用戶切換目錄,直接切換到當前的版本目錄:{release_library}/{project}/{version}
$cmd[] = "cd {$version}";
foreach ($tasks as $task) {
$cmd[] = preg_replace($pattern, $replace, $task);
}
return join(' && ', $cmd);
}