Skip to content

Commit

Permalink
各种笔误修改。。。
Browse files Browse the repository at this point in the history
  • Loading branch information
xsir317 committed Dec 1, 2014
1 parent b0d10b0 commit 4e9481a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
1 change: 1 addition & 0 deletions publisher/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ composer.lock
.env.php
.DS_Store
Thumbs.db
app/storage
39 changes: 22 additions & 17 deletions publisher/app/lib/TaskHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,17 @@ public function run($task_id)
return $this->err('供执行的任务必须是初始状态');
}
//TODO 检查前置任务pre_task 的状态
if($task->pre_task && $task->pre()->status != 'success')
if($task->pre_task && $task->pre->status != 'success')
{
return $this->err('前置任务尚未完成');
}
$task->status = 'execute';
$task->execute_time = date('Y-m-d H:i:s');
$task->save();
$func = '_run'.ucfirst($task->type);
return $this->$func($task);
$result = $this->$func($task);
$task->status = $result['result'] ? 'success':'failed';
$task->save();
}

/**
Expand All @@ -86,25 +88,25 @@ private function _runCheckout($task)
{
if($task->project_id)
{
$pj_dir = Project::getTempDir($task->project_id);//项目代码存放目录
$pj_dir = \Project::getTempDir($task->project_id);//项目代码存放目录
if(!file_exists($pj_dir))
{
if(!mkdir($pj_dir,0750))
{
return array('result'=>false,'output'=>"mkdir $pj_dir failed!");
}
}
$project = Project::find($project_id);
$project = \Project::find($task->project_id);
switch ($project->vcs_type) {
case 'svn':
if(function_exists('svn_checkout'))
if(false)//function_exists('svn_checkout'))
{
if($project->username)
{
svn_auth_set_parameter(SVN_AUTH_PARAM_DEFAULT_USERNAME, $project->username);
svn_auth_set_parameter(SVN_AUTH_PARAM_DEFAULT_PASSWORD, $project->password);
}
$result = svn_checkout($project->svn_addr,$pj_dir);
$result = svn_checkout($project->src_addr,$pj_dir);
if($result)
{
$project->current_version = $this->get_dir_version($pj_dir);
Expand All @@ -114,8 +116,11 @@ private function _runCheckout($task)
}
else
{
$command = "svn checkout {$project->svn_addr} {$pj_dir} ";
$command .= " --no-auth-cache --username={$project->username} --password={$project->password}";
$command = "svn checkout {$project->src_addr} {$pj_dir} --no-auth-cache";
if($project->username)
{
$command .= " --username={$project->username} --password={$project->password}";
}
exec($command,$output,$return_var);
if($return_var == 0)
{
Expand All @@ -140,8 +145,8 @@ private function _runUpdate($task)

if($task->project_id)
{
$pj_dir = Project::getTempDir($task->project_id);
$project = Project::find($project_id);
$pj_dir = \Project::getTempDir($task->project_id);
$project = \Project::find($task->project_id);
switch ($project->vcs_type) {
case 'svn':
if(function_exists('svn_update'))
Expand All @@ -151,7 +156,7 @@ private function _runUpdate($task)
svn_auth_set_parameter(SVN_AUTH_PARAM_DEFAULT_USERNAME, $project->username);
svn_auth_set_parameter(SVN_AUTH_PARAM_DEFAULT_PASSWORD, $project->password);
}
$result = svn_update($project->svn_addr,$pj_dir,$task->version);
$result = svn_update($pj_dir,$task->version);
if($result !== false)
{
$project->current_version = $this->get_dir_version($pj_dir);
Expand All @@ -161,7 +166,7 @@ private function _runUpdate($task)
}
else
{
$command = "svn update {$project->svn_addr} {$pj_dir} -r {$task->version}";
$command = "svn update {$pj_dir} -r {$task->version}";
$command .= " --no-auth-cache --username={$project->username} --password={$project->password}";
exec($command,$output,$return_var);
if($return_var == 0)
Expand All @@ -187,7 +192,7 @@ private function _runDelete($task)
{
if($task->project_id)
{
$pj_dir = Project::getTempDir($task->project_id);
$pj_dir = \Project::getTempDir($task->project_id);
if(!file_exists($pj_dir))
{
if(!mkdir($pj_dir,0750))
Expand All @@ -201,7 +206,7 @@ private function _runDelete($task)
exec($delete_cmd,$output,$return_var);
if($return_var == 0)
{
$project = Project::find($project_id);
$project = \Project::find($project_id);
$project->current_version = '';
$project->save();
}
Expand All @@ -218,12 +223,12 @@ private function _runDelete($task)
*/
private function _runRsync($task)
{
$server = Server::find($task->server_id);
$pj_dir = Project::getTempDir($server->project_id);
$server = \Server::find($task->server_id);
$pj_dir = \Project::getTempDir($server->project_id);
//目前就记录个日志就得了
$rsync_cmd = sprintf("rsync -avzP publisher@%s::%s %s",$server->ip,$server->rsync_name,$pj_dir);
//忽略文件、 发布时要添加del选项
file_put_contents(app_path()."/storage/rsync.log",$rsync_cmd,FILE_APPEND);
file_put_contents(app_path()."/storage/rsync.log",$rsync_cmd."\n",FILE_APPEND);
if(true)
{
$server->current_version = $this->get_dir_version($pj_dir);
Expand Down
2 changes: 1 addition & 1 deletion publisher/app/models/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function servers()
}

//project临时目录
public function getTempDir($_id)
public static function getTempDir($_id)
{
return app_path().'/storage/pjfolder_'.intval($_id);
}
Expand Down
2 changes: 1 addition & 1 deletion publisher/app/views/projects/publish.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
for (var _key in _data.logs )
{
_order[_order.length] = _key;
if(isNan(_key)) is_numeric = false;
if(isNaN(_key)) is_numeric = false;
}
if(is_numeric) _order.reverse();
for (var _key in _order ) {
Expand Down

0 comments on commit 4e9481a

Please sign in to comment.