本文整理匯總了PHP中app\models\Project::getDeployWorkspace方法的典型用法代碼示例。如果您正苦於以下問題:PHP Project::getDeployWorkspace方法的具體用法?PHP Project::getDeployWorkspace怎麽用?PHP Project::getDeployWorkspace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Project
的用法示例。
在下文中一共展示了Project::getDeployWorkspace方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: updateToVersion
/**
* 更新到指定commit版本
*
* @param string $commit
* @return bool
*/
public function updateToVersion($task)
{
$copy = GlobalHelper::str2arr($task->file_list);
$fileAndVersion = [];
foreach ($copy as $file) {
$fileAndVersion[] = StringHelper::explode($file, " ", true, true);
}
$branch = $task->branch == 'trunk' ? $task->branch : ($this->getConfig()->repo_mode == Project::REPO_BRANCH ? 'branches/' : 'tags/') . $task->branch;
// 先更新
$versionSvnDir = sprintf('%s-svn', rtrim(Project::getDeployWorkspace($task->link_id), '/'));
$cmd[] = sprintf('cd %s ', $versionSvnDir);
$cmd[] = $this->_getSvnCmd(sprintf('svn checkout %s/%s .', $this->getConfig()->repo_url, $branch));
// 更新指定文件到指定版本,並複製到同步目錄
foreach ($fileAndVersion as $assign) {
if (in_array($assign[0], ['.', '..'])) {
continue;
}
$cmd[] = $this->_getSvnCmd(sprintf('svn up %s %s', $assign[0], empty($assign[1]) ? '' : ' -r ' . $assign[1]));
// 多層目錄需要先新建父目錄,否則複製失敗
if (strpos($assign[0], '/') !== false) {
$cmd[] = sprintf('mkdir -p %s/%s', Project::getDeployWorkspace($task->link_id), dirname($assign[0]));
}
$cmd[] = sprintf('cp -rf %s %s/%s', rtrim($assign[0], '/'), Project::getDeployWorkspace($task->link_id), dirname($assign[0]));
}
$command = join(' && ', $cmd);
return $this->runLocalCommand($command);
}
示例2: updateToVersion
/**
* 更新到指定commit版本
*
* @param TaskModel $task
* @return bool|int
*/
public function updateToVersion(TaskModel $task)
{
// 先更新
$versionSvnDir = rtrim(Project::getDeployWorkspace($task->link_id), '/');
$cmd[] = sprintf('cd %s ', $versionSvnDir);
$cmd[] = $this->_getSvnCmd(sprintf('svn up -q --force -r %d', $task->commit_id));
$command = join(' && ', $cmd);
return $this->runLocalCommand($command);
}
示例3: updateToVersion
/**
* 更新到指定commit版本
*
* @param string $commit
* @return bool
*/
public function updateToVersion($task)
{
// 先更新
$destination = Project::getDeployWorkspace($task->link_id);
$this->updateRepo($task->branch, $destination);
$cmd[] = sprintf('cd %s ', $destination);
$cmd[] = sprintf('/usr/bin/env git reset -q --hard %s', $task->commit_id);
$command = join(' && ', $cmd);
return $this->runLocalCommand($command);
}
示例4: updateToVersion
/**
* 更新到指定commit版本
*
* @param string $commit
* @return bool
*/
public function updateToVersion($commit, $version)
{
// 先更新
$destination = Project::getDeployWorkspace($version);
$this->updateRepo('master', $destination);
$cmd[] = sprintf('cd %s ', $destination);
$cmd[] = sprintf('/usr/bin/env git reset %s', $commit);
$cmd[] = '/usr/bin/env git checkout .';
$command = join(' && ', $cmd);
return $this->runLocalCommand($command);
}
示例5: 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 = rtrim(Project::getDeployWorkspace($version), '/');
$version = Project::getReleaseVersionDir($version);
$pattern = ['#{WORKSPACE}#', '#{VERSION}#'];
$replace = [$workspace, $version];
foreach ($tasks as $task) {
$cmd[] = preg_replace($pattern, $replace, $task);
}
return join(' && ', $cmd);
}
示例6: postDeploy
/**
* post-deploy部署代碼後置觸發任務
* git代碼檢出之後,可能做一些調整處理,如vendor拷貝,配置環境適配(mv config-test.php config.php)
*
* @return bool
*/
public function postDeploy($version)
{
$tasks = GlobalHelper::str2arr($this->getConfig()->post_deploy);
if (empty($tasks)) {
return true;
}
$cmd = [];
$workspace = rtrim(Project::getDeployWorkspace($version), '/');
$pattern = ['#{WORKSPACE}#'];
$replace = [$workspace];
foreach ($tasks as $task) {
$cmd[] = preg_replace($pattern, $replace, $task);
}
$command = join(' && ', $cmd);
return $this->runLocalCommand($command);
}
示例7: postDeploy
/**
* post-deploy部署代碼後置觸發任務
* git代碼檢出之後,可能做一些調整處理,如vendor拷貝,配置環境適配(mv config-test.php config.php)
*
* @return bool
*/
public function postDeploy($version)
{
$tasks = GlobalHelper::str2arr($this->getConfig()->post_deploy);
if (empty($tasks)) {
return true;
}
// 本地可能要做一些依賴環境變量的命令操作
$cmd = ['source /etc/profile'];
$workspace = rtrim(Project::getDeployWorkspace($version), '/');
$pattern = ['#{WORKSPACE}#'];
$replace = [$workspace];
// 簡化用戶切換目錄,直接切換到當前部署空間:{deploy_from}/{env}/{project}-YYmmdd-HHiiss
$cmd[] = "cd {$workspace}";
foreach ($tasks as $task) {
$cmd[] = preg_replace($pattern, $replace, $task);
}
$command = join(' && ', $cmd);
return $this->runLocalCommand($command);
}
示例8: updateToVersion
/**
* 更新到指定commit版本
*
* @param TaskModel $task
* @return bool|int
*/
public function updateToVersion(TaskModel $task)
{
// 兼容無trunk、無branches、無tags下為空
$branch = $task->branch == 'trunk' || $task->branch == '' ? $task->branch : ($this->getConfig()->repo_mode == Project::REPO_BRANCH ? 'branches/' : 'tags/') . $task->branch;
// 先更新
$versionSvnDir = sprintf('%s-svn', rtrim(Project::getDeployWorkspace($task->link_id), '/'));
$cmd[] = sprintf('cd %s ', $versionSvnDir);
$cmd[] = $this->_getSvnCmd(sprintf('svn checkout -q %s/%s .', $this->getConfig()->repo_url, $branch));
// 更新指定文件到指定版本,並複製到同步目錄
$fileAndVersion = $this->getFileAndVersionList($task);
foreach ($fileAndVersion as $assign) {
if (in_array($assign['file'], ['.', '..'])) {
continue;
}
$cmd[] = $this->_getSvnCmd(sprintf('svn up -q %s %s', $assign['file'], empty($assign['version']) ? '' : ' -r ' . $assign['version']));
// 多層目錄需要先新建父目錄,否則複製失敗
if (strpos($assign['file'], '/') !== false) {
$cmd[] = sprintf('mkdir -p %s/%s', Project::getDeployWorkspace($task->link_id), dirname($assign['file']));
}
$cmd[] = sprintf('cp -rf %s %s/%s', rtrim($assign['file'], '/'), Project::getDeployWorkspace($task->link_id), dirname($assign['file']));
}
$command = join(' && ', $cmd);
return $this->runLocalCommand($command);
}
示例9: cleanUpLocal
/**
* 收尾做處理工作,如清理本地的部署空間
*
* @param $version
* @return bool|int
*/
public function cleanUpLocal($version)
{
$cmd[] = "rm -rf " . Project::getDeployWorkspace($version);
if ($this->config->repo_type == Project::REPO_SVN) {
$cmd[] = sprintf('rm -rf %s-svn', rtrim(Project::getDeployWorkspace($version), '/'));
}
$command = join(' && ', $cmd);
return $this->runLocalCommand($command);
}
示例10: cleanUpLocal
/**
* 收尾做處理工作,如清理本地的部署空間
*
* @param $version
* @return bool|int
*/
public function cleanUpLocal($version)
{
$cmd[] = 'rm -rf ' . Project::getDeployWorkspace($version);
$cmd[] = sprintf('rm -f %s/*.tar.gz', dirname(Project::getDeployPackagePath($version)));
$command = join(' && ', $cmd);
return $this->runLocalCommand($command);
}
示例11: cleanUp
/**
* 收尾做處理工作,如清理本地的部署空間
*
* @param $version
* @return bool|int
*/
public function cleanUp($version)
{
$command = "rm -rf " . Project::getDeployWorkspace($version);
return $this->runLocalCommand($command);
}