With the simple example below, Jenkins will run ant command to run scripts defined in build.xml file in your project called Nation.


Install Ant


$ sudo apt-get update
$ sudo apt-get install ant

Build.xml


Assume that you have build.xml file under /workspace/Nation/ projects.


<?xml version="1.0" encoding="UTF-8"?>

<project name="nation" default="full-suite" basedir=".">

<!-- GLOBAL VARIABLES -->
<property name="source" value="app" />
<!-- END -->

<!-- AVAILABLE COMMANDS -->
<target name="full-suite" depends="date, list" />
<!-- END -->

<!-- DATE -->
<target name="date">
<echo message="Printing system date ..."/>
<exec executable="date" />
</target>
<!-- END -->

<!-- LIST -->
<target name="list">
<echo message="Listing source folder ..."/>
<exec executable="ls">
<arg line="-l ${source}" />
</exec>
</target>
<!-- END -->

</project>

Manual test


Currently we're logged in as vagrant user in out vagrant machine. Lets switch to jenkins user to update build.xml and run tests.


$ vagrant@jenkins:~$
$ vagrant@jenkins:~$ sudo su -l jenkins

$ jenkins@jenkins:~$
$ jenkins@jenkins:~$ cd workspace/Nation/
$ jenkins@jenkins:~/workspace/Nation$ $ ant -file build.xml
Buildfile: /var/lib/jenkins/workspace/Nation/build.xml

date:
[echo] Printing system date ...
[exec] Wed Jan 18 11:11:55 UTC 2017

list:
[echo] Listing source folder ...
[exec] total 4
[exec] drwxr-xr-x 12 jenkins jenkins 4096 Jan 18 09:57 AppBundle

full-suite:

BUILD SUCCESSFUL
Total time: 0 seconds

Jenkins Ant configuration



Jenkins test


I assume that there is a build in your "Build History" so just manually build. If you go to "Console Output" of your build, you should see something like below.