I’m having issues with sshsession Ant task.
I’m writing a deploy script which bzip sources, scp the archive to a remote server and then unzip sources on the remote server and copy files in the right directory tree.
(...)
<bzip2 src="/tmp/${selected.target}.tar" destfile="/tmp/${selected.target}.tar.bz2"/>
<scp file="/tmp/${selected.target}.tar.bz2" todir="user@server:/tmp/" keyfile="${user.home}/.ssh/id_rsa" trust="yes" passphrase="thisisasecret"/>
<sshsession host="server" username="user" keyfile="${user.home}/.ssh/id_rsa" trust="yes">
<sequential>
<untar src="/tmp/${selected.target}.tar.bz2" dest="/tmp/prova_untar" compression="bzip2"/>
(copy files)
</sequential>
</sshsession>
(...)
My problem is with tasks specified inside the sshsession, since they are executed locally and not on the remote server. I thought (but clearly i’m wrong) that command specified within sshsession tag would be executed on the server i just connected to. I read in the documentation that you can specify tunnels with localtunnel and remotetunnel, but i’m not sure i’m understanding correctly what those tunnels are for. Does anyone has encountered the same problem, or has a solution for that? The Ant version i’m working with is 1.8.2.
Thanks,
Alberto
I add a answer to show how we use the remote-build.xml.
For example, we want to deploy some pre-built SQL files to the database server, insert the sql files into a database in MySQL and restart mysql.
So when deploying, we packed the sql file archive (sample-sql.zip) together with “my-company-lib.jar” and “remote-build.xml” and then transfer the archive file with
scp.Then, sshexec “ant -f remote-build.xml run” (you can either put the properties in a properties file or transfer them in the sshexec commandline).