Monday, December 28, 2009

Trobleshooting Hudson and Ant

[catalog-server] $ cmd.exe /C '"ant.bat -file build.xml install && exit %%ERRORLEVEL%%"'
'ant.bat' is not recognized as an internal or external command, operable program or batch file.
Finished: FAILURE

1) The machine which runs Hudson might not have ANT installed on it.
2) If ANT is installed on it then you might not have set the ANT_HOME variable.
3) If ANT_HOME is set, then you might not have set %ANT_HOME%\bin as a part of the system PATH variable.
4) If that is also set, then you may have started your application server (tomcat\hudson) before you performed steps 1-3 so the changes haven't taken effect yet, try restarting it.
5) No good? You may be starting or stopping the tomcat container as a windows service BUT the user under whom the service actually runs may be a different one! This means you need to log that user out and then back-in for him/her to pick up the changes made to the system variables like ANT_HOME or PATH. You can simply reboot your machine if you don't know who that user is or what their password happens to be.
6) No luck? Goto Hudson > Manage Hudson > Configure System > Ant and fill out a value for the ANT_HOME variable and then click Save.
7) Still no luck? Well go to the Job in question and then goto Configure > Build > Invoke Ant > Ant Version and change it from (Default) to the one you configured in the previous step.

If this is not enough try having a look at: http://blog.mxunit.org/2009/05/ci-with-hudson-cf-and-mxunit.html