{"id":945,"date":"2013-07-03T12:34:04","date_gmt":"2013-07-03T17:34:04","guid":{"rendered":"http:\/\/osric.com\/chris\/accidental-developer\/?p=945"},"modified":"2013-07-03T14:30:36","modified_gmt":"2013-07-03T19:30:36","slug":"ant-deployment-script-and-sftp","status":"publish","type":"post","link":"https:\/\/osric.com\/chris\/accidental-developer\/2013\/07\/ant-deployment-script-and-sftp\/","title":{"rendered":"ANT deployment script and SFTP"},"content":{"rendered":"<p>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.<\/p>\n<p>Although I previously used <a href=\"http:\/\/ant.apache.org\/\">Apache Ant<\/a> scripts through <a href=\"http:\/\/www.eclipse.org\/\">Eclipse<\/a> 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.<\/p>\n<p>Here is a revised Ant script that uses SCP (Secure Copy)&#8211;not SFTP but achieves the same goal&#8211;to deploy application files from a developer sandbox to the development or production server:<\/p>\n<pre><code>&lt;project name=\"Deploy myapp\" default=\"Sandbox to Dev\"&gt;\r\n  &lt;input message=\"Username:\" addproperty=\"username\" \/&gt;\r\n  &lt;input message=\"Password:\" addproperty=\"passwd\" \/&gt;\r\n  &lt;property name=\"applicationFolder\" value=\"myapp\"\/&gt;\r\n  &lt;property name=\"site\" value=\"osric.com\"\/&gt;\r\n  &lt;property name=\"sandboxRoot\" value=\"${basedir}\"\/&gt;\r\n  &lt;property \r\n    name=\"development\" \r\n    value=\"${username}:${passwd}@dev.osric.com:\/home\/web\/${site}\/${applicationFolder}\"\/&gt;\r\n  &lt;property \r\n    name=\"production\" \r\n    value=\"${username}:${passwd}@osric.com:\/home\/web\/${site}\/${applicationFolder}\"\/&gt;\r\n  &lt;target name=\"Sandbox to Dev\"&gt;\r\n    &lt;scp todir=\"${development}\" trust=\"true\"&gt;\r\n      &lt;fileset dir=\"${sandboxRoot}\"&gt;\r\n        &lt;exclude name=\"**\/build.xml\"\/&gt;\r\n        &lt;exclude name=\"**\/.*\"\/&gt;\r\n      &lt;\/fileset&gt;\r\n    &lt;\/scp&gt;\r\n  &lt;\/target&gt;\r\n  &lt;target name=\"Sandbox to Production\"&gt;\r\n    &lt;scp todir=\"${production}\" trust=\"true\"&gt;\r\n      &lt;fileset dir=\"${sandboxRoot}\"&gt;\r\n        &lt;exclude name=\"**\/build.xml\"\/&gt;\r\n        &lt;exclude name=\"**\/.*\"\/&gt;\r\n      &lt;\/fileset&gt;\r\n    &lt;\/scp&gt;\r\n  &lt;\/target&gt;\r\n&lt;\/project&gt;<\/code><\/pre>\n<p>There are a couple issues with this script to be aware of:<\/p>\n<ul>\n<li>SCP is not included with Ant. The script produced the error &#8220;Problem: failed to create task or type scp&#8221;. I needed to:\n<ol>\n<li>Download <a href=\"http:\/\/www.jcraft.com\/jsch\/\">JSCH<\/a><\/li>\n<li>Place the file in Eclipse&#8217;s plugins\/[ant folder]\/lib folder<\/li>\n<li>Add the JAR file to the Ant build path (via Window&#8211;Preferences&#8211;Ant Home Entries (default)&#8211;Add External JARs&#8230;&#8211;select the jsch .jar file)<\/li>\n<\/ol>\n<li>The password input is in plain text. <a href=\"http:\/\/www.dcepler.net\/post.cfm\/hiding-password-input-in-ant\">Hiding password input in Ant<\/a> provides a solution for Ant, but one that does not work from Eclipse. I have seen other possible solutions, so I&#8217;ll update this once I implement once and confirm that it works.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/osric.com\/chris\/accidental-developer\/2013\/07\/ant-deployment-script-and-sftp\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">ANT deployment script and SFTP<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,232],"tags":[304,305,306],"class_list":["post-945","post","type-post","status-publish","format-standard","hentry","category-process","category-tips-tricks","tag-ant","tag-deployment","tag-eclipse"],"_links":{"self":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/945","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/comments?post=945"}],"version-history":[{"count":7,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/945\/revisions"}],"predecessor-version":[{"id":955,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/945\/revisions\/955"}],"wp:attachment":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/media?parent=945"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/categories?post=945"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/tags?post=945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}