Skip to content

Instantly share code, notes, and snippets.

@Yuav Yuav/build.xml
Last active Jun 22, 2016

What would you like to do?
Puppet module testing with acceptance tests in parallel using Apache Ant. Simplifies integration with Jenkins
<?xml version="1.0" encoding="UTF-8"?>
<project name="project" default="build">
<target name="build" depends="clean,bundle-install,syntax,lint">
<antcall target="spec" />
<antcall target="acceptance" />
<target name="clean">
<delete includeemptydirs="true" removeNotFollowedSymlinks="true" failonerror="false">
<fileset followSymlinks="no" dir="${basedir}/spec/fixtures/modules" defaultexcludes="no">
<include name="**/*" />
<exclude name="**/*~" />
<exclude name="**/#*#" />
<exclude name="**/.#*" />
<exclude name="**/%*%" />
<delete file="${basedir}/Gemfile.lock" failonerror="false" />
<target name="rvm" description="Prepare RVM">
<exec executable="${user.home}/.rvm/scripts/rvm" />
<exec executable="rvm">
<arg line="use 'ruby@gemset'" />
<target name="bundle-install" depends="rvm" description="Install dependencies using Bundler">
<exec executable="bundle" failonerror="true">
<arg value="install" />
<target name="syntax" description="Check syntax of manifest files">
<exec executable="bundle" failonerror="true">
<arg line="exec rake syntax" />
<target name="lint" description="Check lint of manifest and template files">
<exec executable="bundle" failonerror="true">
<arg line="exec rake lint" />
<exec executable="${basedir}/spec/" failonerror="true" />
<target name="spec" description="Run spec tests">
<exec executable="bundle" failonerror="true">
<env key="CI_REPORTS" value="${basedir}/results/spec" />
<arg line="exec rake spec" />
<target name="acceptance" description="Run acceptance tests in parallel">
<script language="javascript">
fs = project.createDataType("fileset");
dir = "spec/acceptance/nodesets";
fs.setDir( new dir ) );
fs.setIncludes( "**/*.yml" );
// create parallel Task via Ant API
parent = project.createTask("parallel");
// iterate over files found.
srcFiles = fs.getDirectoryScanner( project ).getIncludedFiles( );
for ( i = 0; i < srcFiles.length; i++ ) {
var filename = srcFiles[i];
var nodename = filename.replace( '.yml', '');
if (nodename == 'default') {
// Set param for antcall
ac = project.createTask("antcall");
<target name="acceptance-build">
<echo message="Starting nodeset: ${nodeset}" />
<property environment="env" />
<exec executable="bundle" failonerror="true">
<env key="CI_REPORTS" value="${basedir}/results/acceptance" />
<env key="BEAKER_set" value="${nodeset}" />
<env key="BEAKER_debug" value="true" />
<arg line="exec rake acceptance" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.