Jenkins build error - Cannot start ant program

I have build.xml configured to run a project to run selenium test cases. I have a Mac computer and I can run ant from the terminal. But when I try to escape from the Jenkins, I get the following error. I specified ant home in Jenkins configuration

/usr/local/Cellar/ant/1.9.4/libexec

I used homebrew to install ANT
FATAL: command execution failed.Maybe you need to configure the job to choose one of your Ant installations? java.io.IOException: Cannot run program "ant" (in directory "/Users/Shared/Jenkins/Home/workspace/BaublebarTest"): error=2, No such file or directory at java.lang.ProcessBuilder.processException(ProcessBuilder.java:478) at java.lang.ProcessBuilder.start(ProcessBuilder.java:457) at hudson.Proc$LocalProc.<init>(Proc.java:244) at hudson.Proc$LocalProc.<init>(Proc.java:216) at hudson.Launcher$LocalLauncher.launch(Launcher.java:802) at hudson.Launcher$ProcStarter.start(Launcher.java:380) at hudson.Launcher$ProcStarter.join(Launcher.java:387) at hudson.tasks.Ant.perform(Ant.java:217) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770) at hudson.model.Build$BuildExecution.build(Build.java:199) at hudson.model.Build$BuildExecution.doRun(Build.java:160) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:533) at hudson.model.Run.execute(Run.java:1754) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:89) at hudson.model.Executor.run(Executor.java:240) Caused by: java.io.IOException: error=2, No such file or directory at java.lang.UNIXProcess. enter the code here forkAndExec(Native Method) at java.lang.UNIXProcess.<init>(UNIXProcess.java:53) at java.lang.ProcessImpl.start(ProcessImpl.java:91) at java.lang.ProcessBuilder.start(ProcessBuilder.java:452) ... 15 more Build step 'Invoke Ant' marked build as failure Finished: FAILURE

+6
source share
2 answers

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

+7
source

I do not use terminal for jenkins, but I was getting the same error. Changing the default version of Ant to Ant fixed bugs.

+6
source

Source: https://habr.com/ru/post/976834/


All Articles