First, the right way
Jenkins will install Ant (and other tools for you). In the global configuration (Jenkins Management), configure the Ant installation by selecting the version and source.
Then, when you run the Ant build step, you can choose the version, either default , or the one you just configured. When the build is complete, Jenkins will download, install and configure a specific version for you ( only in Jenkins ), without affecting the rest of the OS. Installation should be performed only once per node, and then quickly.
default
This default version is the backup that Jenkins uses when you have not configured the correct version to use. It tries to use everything that is available on the command line by simply executing Ant from the current working directory.
You said that this works for you when you just type Ant at the command line, but you should understand that Jenkins works under jenkins user and not with your user, and something like ANT_HOME and the correct path to Ant is probably configured specifically for your user.
So, to fix your problem, either use the appropriate method for Jenkins to complete the installation of the tool, or correctly configure the tool at the OS level for the jenkins user.
You can start by typing:
sudo su jenkins
Ant
And see if this works from user jenkins
source share