umar
umar

Reputation: 4389

how to execute rake tasks from an ant script

i need to write an ant (build.xml) file to do the following: - run 'rake test' - run 'rake rspec' - run 'rake features' - if all of the above pass, then do a 'cap deploy staging'

I am new to ant scripts, and so far, i have done:

<project name="myapp" basedir=".">
  <target name="run-migrations">
    <exec executable="rake">
      <arg value="db:migrate"></arg>
    </exec>
  </target>
  <target name="load-rake-task" depends="run-migrations">
    <exec executable="rake"></exec>
  </target>
  ...
</project>

This runs rake db:migrate, followed by rake, but i have not yet figured out how to capture the output of the running of the command, and better still, how to access if any of the tests failed.

How can i modify the above script to capture output and find out how many tests passed and failed in the above scenario?

Upvotes: 0

Views: 632

Answers (1)

Rebse
Rebse

Reputation: 10377

To capture the output use the following attributes from exec task :

  1. outputproperty for stdout
  2. errorproperty for stderr
  3. resultproperty for RC (returncode)

means something like that :

<exec executable="rake" outputproperty="rake.out" errorproperty="rake.err" resultproperty="rake.rc">
  <arg value="db:migrate"></arg>
</exec>

also it's recommended to use failonerror="true", default is false.

see Ant manual / exec task for the details.

Upvotes: 1

Related Questions