Question

I would like to do remote deployment from my build machine onto a server. The remoting can be done via ssh commands from a script, but I would rather use phing and a deploy.xml file that would do the automation.

What alternatives do I have to do ssh (and also scp) tasks from within a phing build file?

Was it helpful?

Solution

If you really need phing, then afaik there's only exec. If you are open for other tools, have a look at capistrano and my answer in "Setting up a PHP web project, the infrastructure.".

OTHER TIPS

SCPTask in Phing:

copies files to and from a remote host using scp. This task requires the PHP SSH2 extension to function...

I came across a SCP and SSH tasks for Phing yesterday. You will also need to follow the instructions for installing SSH2 for PHP. I wasn't able to get the tasks to work straight out of the box, you might. I modified my copy, if you need I can provide.

I ran into the same problem about a year ago and back then i could not find a task. I ended up doing a exec task, this way it was all in the xml file.

<exec command="scp -i keys/id_rsa myfile user@$server:myfile" dir="." />

I know this is old but there seems to be multiple broken links and some misinformation.

ScpTask: http://www.phing.info/docs/guide/stable/apcs60.html

SshTask: http://www.phing.info/docs/guide/stable/apcs60.htm

For SemanticScuttle, we use rsync to deploy release files to the SourceForge server - also via exec. Rsync understands ssh.

For ssh, there's the ssh2 PECL extension and then Phing has the ssh and scp tasks.

  1. On a Mac, install libssh2 via Homebrew. On Linux, use your package manager.
  2. sudo pecl install pecl.php.net/ssh2-0.12

You can now do this:

<?xml version="1.0"?>
<project name="test" default="test">
  <target name="test">
    <ssh username="vagrant" password="vagrant" host="192.168.123.456"
        command="pwd" property="pwd" display="false" />
    <echo>The current working directory is ${pwd}</echo>
  </target>
</project>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top