netbeans automated deployment with ant and rsync

since i have a few chances to correctly remember rsync deployment command and since a wrong command could be a disaster, let’s try to automatically perform it via netbeans-ant integration: http://stackoverflow.com/questions/14545945/how-to-sync-a-php-project-using-rsync-and-netbeans.

cp options:
-R -> nicely manages symbolic links

rsync options:
-a -> stands for “archive” and syncs recursively and preserves symbolic links, special and device files, modification times, group, owner, and permissions.
-n -> dry-run
-P -> nice verbosity
-z -> compress

then i create deploy.ant in ~/eERP/:

<?xml version="1.0" encoding="UTF-8"?>
<project name="eERP" default="dev-to-test-deployment">
    <property name="username" value="user"/>
    <property name="host" value="ams15.siteground.eu"/>
    <property name="localDevPath" value="/home/teo/eERP/dev/"/>
    <property name="localDevBackup" value="/home/teo/eERP/dev-backup"/>
    <property name="remoteTestPath" value="/home/user/test"/>

    <target name="dev-to-test-deployment">
        <exec dir="." executable="rm" failonerror="false">
            <arg value="-rf"/>
            <arg value="${localDevBackup}"/>
        </exec>

        <exec dir="." executable="mkdir" failonerror="true">
            <arg value="${localDevBackup}"/>
        </exec>

        <exec dir="." executable="cp" failonerror="true">
            <arg value="-R"/>
            <arg value="${localDevPath}."/>
            <arg value="${localDevBackup}/"/>
        </exec>

        <exec dir="." executable="rsync" failonerror="true">
            <arg value="-azP"/>
            <arg value="--delete"/>
            <arg value="-e"/>
            <arg value="ssh -p 18765"/>
            <arg value="${localDevPath}"/>
            <arg value="${username}@${host}:${remoteTestPath}"/>
        </exec>
    </target>
</project>

activate ant plugin in netbeans.
right click on deploy.ant -> run target… -> dev-to-test-deployment

-> perfect!

One thought on “netbeans automated deployment with ant and rsync

Leave a comment