Skip to content

Commit 83aebe4

Browse files
committed
added event parameter to task runners;
passing applicationPath to run() command
1 parent 56d4f75 commit 83aebe4

3 files changed

Lines changed: 30 additions & 6 deletions

File tree

module/DeployAgent/src/Task/Runner/Command.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
namespace Continuous\DeployAgent\Task\Runner;
1212

13+
use Zend\EventManager\Event;
14+
1315
/**
1416
* Command
1517
*
@@ -39,9 +41,11 @@ public function setCommand($command)
3941
return $this;
4042
}
4143

42-
public function run()
44+
public function run(Event $e)
4345
{
44-
passthru($this->getCommand(), $return);
46+
$applicationPath = $e->getParam('applicationPath');
47+
48+
passthru("cd $applicationPath && " . $this->getCommand(), $return);
4549
if ($return) {
4650
throw new Exception('The command exit with code ' . $return, Exception::BAD_EXIT_EXCEPTION);
4751
}

module/DeployAgent/src/Task/Runner/TaskRunnerInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
namespace Continuous\DeployAgent\Task\Runner;
1212

13+
use Zend\EventManager\Event;
14+
1315
/**
1416
* TaskRunnerInterface
1517
*
@@ -19,5 +21,5 @@
1921
*/
2022
interface TaskRunnerInterface
2123
{
22-
public function run();
24+
public function run(Event $e);
2325
}

module/DeployAgent/src/Task/TaskManager.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,25 @@ public function activate(EventInterface $event)
279279
$this->loadConfig($configFile);
280280
}
281281

282-
$application->getEventManager()->trigger($application::EVENT_AFTER_INSTALL);
282+
$application->getEventManager()->trigger(
283+
$application::EVENT_AFTER_INSTALL,
284+
null,
285+
[
286+
'applicationPath' => $application->getPath() . DIRECTORY_SEPARATOR . $build
287+
]
288+
);
283289

284290
if (file_exists($application->getPath() . DIRECTORY_SEPARATOR . 'current')) {
285291
unlink($application->getPath() . DIRECTORY_SEPARATOR . 'current');
286292
}
287293

288-
$application->getEventManager()->trigger($application::EVENT_BEFORE_ACTIVATE);
294+
$application->getEventManager()->trigger(
295+
$application::EVENT_BEFORE_ACTIVATE,
296+
null,
297+
[
298+
'applicationPath' => $application->getPath() . DIRECTORY_SEPARATOR . $build
299+
]
300+
);
289301

290302
$message = 'Starting ' . $application->getName() . ' (' . $build . ')';
291303
$this->getLogger()->info($message);
@@ -295,7 +307,13 @@ public function activate(EventInterface $event)
295307
$application->getPath() . DIRECTORY_SEPARATOR . 'current'
296308
);
297309

298-
$application->getEventManager()->trigger($application::EVENT_AFTER_ACTIVATE);
310+
$application->getEventManager()->trigger(
311+
$application::EVENT_AFTER_ACTIVATE,
312+
null,
313+
[
314+
'applicationPath' => $application->getPath() . DIRECTORY_SEPARATOR . $build
315+
]
316+
);
299317

300318
$message = $application->getName() . ' (' . $build . ') has successfully started';
301319
$this->getLogger()->info($message);

0 commit comments

Comments
 (0)