diff --git a/build.xml b/build.xml
index 6aa56a8beb92ae237fe272c81da9c71865b36bd4..7d1cc1ff6136ba2f1aee30f1be40252891c0b427 100644
--- a/build.xml
+++ b/build.xml
@@ -20,11 +20,32 @@
 
   <!-- Main Target -->
   <target name="main" description="main target">
+    <phingcall target="startup" />
+    <trycatch property="exceptionmsg">
+      <try>
+        <phingcall target="ci-tasks" />
+      </try>
+      <catch>
+        <phingcall target="shutdown" />
+        <fail>Unexpected error during continuous integration tasks -- ${exceptionmsg}</fail>
+      </catch>
+    </trycatch>
+    <phingcall target="shutdown" />
+  </target>
+
+  <!-- Continuous Integration Tasks -->
+  <target name="ci-tasks" description="continuous integration tasks">
 
     <!-- Create dirs -->
     <mkdir dir="${builddir}/reports"/>
     <mkdir dir="${builddir}/reports/coverage"/>
 
+    <!-- PHP CodeSniffer -->
+    <exec command="phpcs --standard=PEAR --extensions=php --report=checkstyle ${srcdir}/module/VuFind/src &gt; ${builddir}/reports/checkstyle.xml" escape="false" />
+
+    <!-- PHPUnit -->
+    <exec dir="${srcdir}/tests" command="VUFIND_LOCAL_DIR=${srcdir}/local phpunit -dzend.enable_gc=0 --log-junit ${builddir}/reports/phpunit.xml --coverage-clover ${builddir}/reports/coverage/clover.xml --coverage-html ${builddir}/reports/coverage/" passthru="true" checkreturn="true" />
+
     <!-- PHP API Documentation -->
     <phpdoc title="API Documentation"
       destdir="${builddir}/apidocs"
@@ -36,12 +57,6 @@
       </fileset>
     </phpdoc>
 
-    <!-- PHP CodeSniffer -->
-    <exec command="phpcs --standard=PEAR --extensions=php --report=checkstyle ${srcdir}/module/VuFind/src &gt; ${builddir}/reports/checkstyle.xml" escape="false" />
-
-    <!-- PHPUnit -->
-    <exec dir="${srcdir}/tests" command="VUFIND_LOCAL_DIR=${srcdir}/local phpunit -dzend.enable_gc=0 --log-junit ${builddir}/reports/phpunit.xml --coverage-clover ${builddir}/reports/coverage/clover.xml --coverage-html ${builddir}/reports/coverage/" passthru="true" checkreturn="true" />
-
   </target>
 
   <!-- Install and Activate VuFind -->