Java – Jenkins and Ant – ant.bat not recognized but env vars are set well

antjavaJenkins

I'm trying to set Jenkins to work with Ant but I get the following error:

Started by user anonymous
Building in workspace C:.jenkins\workspace\CI Demo
Checking out a fresh workspace because there's no workspace at C:.jenkins\workspace\CI Demo
Cleaning local Directory .
Checking out https:///svn/CI_Demo/trunk at revision '2013-10-27T19:34:31.549 +0000'

At revision 6
[CI Demo] $ cmd.exe /C '"ant.bat jar && exit %%ERRORLEVEL%%"'
'ant.bat' is not recognized as an internal or external command,
operable program or batch file.
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE

however, JAVA_HOME, ANT_HOME and I added the following to "Path": %ANT_HOME%\bin;%JAVA_HOME%\bin

And as you can see the command is recognizable when executed in CMD:

C:\Users\Administrator>java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

C:\Users\Administrator>ant -version
Apache Ant(TM) version 1.9.2 compiled on July 8 2013

C:\Users\Administrator>ant.bat
Buildfile: build.xml does not exist!
Build failed

I would appreciate our help.

Thank you,
N

Best Answer

Please set the JAVA_HOME, ANT_HOME, PATH at the Test Node Configuration page as below. While in your JOB Configuration page, make sure you restrict the job run in the correct Test Node and choose "DEFAULT" for your JDK and ANT VERSION. it shall working :D

enter image description here