本文整理汇总了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);
}