To begin with, the best possible way :
-
Jenkins will install Ant (and other tools for you during the installation of jenkins).
-
On the Global Configuration (Manage Jenkins), configure Ant installation, by choosing the version and the source.
-
At that point, when you run an Ant build step, you can pick a version, either default or the one you've recently configured.
-
When the build is executed, Jenkins will download, install, and configure that specific rendition/version for you (within jenkins), without affecting the OS.
The default way :
-
That default version is a fallback that Jenkins utilizes when you haven't configured a appropriate version to utilize.
-
It attempts to utilize whatever is accessible on command line, by executing ant from current working directory.
So to fix your issue, either utilize the first way with Jenkins,installing the tool or appropriately configure the tool on OS level for jenkins user.