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:

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=""/>
    <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 dir="." executable="mkdir" failonerror="true">
            <arg value="${localDevBackup}"/>

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

        <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}"/>

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 Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s