Skip to content

Instantly share code, notes, and snippets.

@kbond
Created May 10, 2011 14:23
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kbond/964568 to your computer and use it in GitHub Desktop.
Save kbond/964568 to your computer and use it in GitHub Desktop.
Symfony2 ant build script template
<?xml version="1.0" encoding="UTF-8" ?>
<project name="[PROJECT_NAME]" default="build" basedir=".">
<property environment="env"/>
<loadfile property="version" srcfile="${basedir}/VERSION"/>
<condition property="bat" value=".bat" else="">
<os family="windows" />
</condition>
<target name="test">
<delete dir="${basedir}/build"/>
<exec executable="php" failonerror="true">
<arg line="app/console cache:clear --env=test"/>
</exec>
<!-- create db and load fixtures -->
<exec executable="php" failonerror="true">
<arg line="app/console doctrine:database:drop --env=test --force"/>
</exec>
<exec executable="php" failonerror="true">
<arg line="app/console doctrine:database:create --env=test"/>
</exec>
<exec executable="php" failonerror="true">
<arg line="app/console doctrine:schema:create --env=test"/>
</exec>
<!-- run tests -->
<exec executable="phpunit${bat}">
<arg line="-c ${basedir}/app"/>
</exec>
<exec executable="php" failonerror="true">
<arg line="app/console doctrine:database:drop --env=test --force"/>
</exec>
</target>
<target name="set_build_info" if="env.BUILD_NUMBER">
<echo message="${version}.${env.BUILD_NUMBER}" file="build.info"/>
</target>
<target name="get_build_info" if="env.build_info_file">
<copy file="${env.build_info_file}" tofile="${basedir}/build.info" overwrite="true" failonerror="false"/>
</target>
<target name="build" depends="test,set_build_info"/>
<target name="deploy" depends="get_build_info">
<mkdir dir="${basedir}/app/cache"/>
<mkdir dir="${basedir}/app/logs"/>
<chmod dir="${basedir}/app/cache" perm="777" />
<chmod dir="${basedir}/app/logs" perm="777" />
<exec executable="rsync">
<arg line="-e &quot;ssh -p ${env.ssh_port}&quot;" />
<arg line="-azC --force --delete --progress" />
<arg line="--exclude-from=app/config/rsync_exclude.txt" />
<arg line="./" />
<arg line="${env.ssh_user}@${env.ssh_host}:${env.server_path}" />
</exec>
<!-- update schema -->
<exec executable="ssh" failonerror="true">
<arg line="${env.ssh_user}@${env.ssh_host} -p ${env.ssh_port} 'sudo -u www-data php ${env.server_path}/app/console doctrine:schema:update --force --env=${env.environment}'"/>
</exec>
<!-- sync db -->
<exec executable="ssh" failonerror="true">
<arg line="${env.ssh_user}@${env.ssh_host} -p ${env.ssh_port} 'sudo -u www-data php ${env.server_path}/app/console zenstruck:db:sync --env=${env.environment}'"/>
</exec>
<!-- clear cache -->
<exec executable="ssh" failonerror="true">
<arg line="${env.ssh_user}@${env.ssh_host} -p ${env.ssh_port} 'sudo -u www-data php ${env.server_path}/app/console cache:clear --env=${env.environment}'"/>
</exec>
<exec executable="ssh" failonerror="true">
<arg line="${env.ssh_user}@${env.ssh_host} -p ${env.ssh_port} 'sudo -u www-data php ${env.server_path}/app/console cache:warmup --env=${env.environment}'"/>
</exec>
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment