My development team is moving away from developing on mapped drives/file shares to using cloud-hosted servers on Amazon Web Services (AWS). This is introducing a change to our usual workflow, as our access to the remote servers is limited to SSH and SFTP.
Although I previously used Apache Ant scripts through Eclipse to facilitate deploying application updates, the scripts were generally unpopular with the rest of the development team. (Many of them do not use Eclipse and preferred just to drop-and-drag files from their development sandboxes to the development or production servers.) Additionally, my original Ant scripts relied on the sync command to synchronize folders on the file shares.
Here is a revised Ant script that uses SCP (Secure Copy)–not SFTP but achieves the same goal–to deploy application files from a developer sandbox to the development or production server:
<project name="Deploy myapp" default="Sandbox to Dev">
<input message="Username:" addproperty="username" />
<input message="Password:" addproperty="passwd" />
<property name="applicationFolder" value="myapp"/>
<property name="site" value="osric.com"/>
<property name="sandboxRoot" value="${basedir}"/>
<property
name="development"
value="${username}:${passwd}@dev.osric.com:/home/web/${site}/${applicationFolder}"/>
<property
name="production"
value="${username}:${passwd}@osric.com:/home/web/${site}/${applicationFolder}"/>
<target name="Sandbox to Dev">
<scp todir="${development}" trust="true">
<fileset dir="${sandboxRoot}">
<exclude name="**/build.xml"/>
<exclude name="**/.*"/>
</fileset>
</scp>
</target>
<target name="Sandbox to Production">
<scp todir="${production}" trust="true">
<fileset dir="${sandboxRoot}">
<exclude name="**/build.xml"/>
<exclude name="**/.*"/>
</fileset>
</scp>
</target>
</project>
There are a couple issues with this script to be aware of:
- SCP is not included with Ant. The script produced the error “Problem: failed to create task or type scp”. I needed to:
- Download JSCH
- Place the file in Eclipse’s plugins/[ant folder]/lib folder
- Add the JAR file to the Ant build path (via Window–Preferences–Ant Home Entries (default)–Add External JARs…–select the jsch .jar file)
- The password input is in plain text. Hiding password input in Ant provides a solution for Ant, but one that does not work from Eclipse. I have seen other possible solutions, so I’ll update this once I implement once and confirm that it works.
So a friend of mine recently convinced me to try using gmail in a different way. His suggestion was that I try archiving all of the mail that I have that no longer requires direct attention, or has some action I must take hanging on it. I have to admit its a pretty appealing idea, since the mail will still show up in searches and whatnot. Shortly following this suggestion I got put on a very high volume mailing list that I also wanted to read many of the emails on. So I decided to give it a try.
So what was a wonderful project to start with became a nightmare, but I finally see the light at the end of the tunnel with it. Because this project started off so innocently, and became such a disaster, I feel like I should share some of the mistakes I made along the way, and some of the insights that I have gained in both 1) extracting myself from the problem and 2) not allowing myself to get sucked into issues like this again. So lets start with a little bit of history of the project and the situation and go from there.
