Azure-pipelines-tasks: "Error: Failed which: Not found ant: null" with Ant task 1.0.56

Created on 6 Feb 2017  路  10Comments  路  Source: microsoft/azure-pipelines-tasks

Hi,
I upgraded to TFS 2017 RTM this weekend for a customer and after the upgrade I get the following error when using the Ant build task (1.0.56): "Error: Failed which: Not found ant: null".

Ant is installed on the server and I have an ANT_HOME path set.

The Ant task log down to the error looks like this:
2017-02-06T12:42:31.8656110Z Set workingFolder to default: D:\Builds\Agent2\tasks\Ant\1.0.56
2017-02-06T12:42:33.8500028Z ##[debug]agent.workFolder=D:\Builds\Agent2_work
2017-02-06T12:42:33.8500028Z ##[debug]loading inputs and endpoints
2017-02-06T12:42:33.8656250Z ##[debug]loading ENDPOINT_AUTH_$/
2017-02-06T12:42:33.8656250Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_$/_ACCESSTOKEN
2017-02-06T12:42:33.8656250Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2017-02-06T12:42:33.8656250Z ##[debug]loading ENDPOINT_AUTH_SCHEME_$/
2017-02-06T12:42:33.8656250Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2017-02-06T12:42:33.8656250Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2017-02-06T12:42:33.8656250Z ##[debug]loading INPUT_ANTBUILDFILE
2017-02-06T12:42:33.8812513Z ##[debug]loading INPUT_CLASSFILESDIRECTORIES
2017-02-06T12:42:33.8812513Z ##[debug]loading INPUT_CODECOVERAGETOOL
2017-02-06T12:42:33.8812513Z ##[debug]loading INPUT_JAVAHOMESELECTION
2017-02-06T12:42:33.8812513Z ##[debug]loading INPUT_JDKARCHITECTURE
2017-02-06T12:42:33.8812513Z ##[debug]loading INPUT_JDKUSERINPUTPATH
2017-02-06T12:42:33.8812513Z ##[debug]loading INPUT_JDKVERSION
2017-02-06T12:42:33.8812513Z ##[debug]loading INPUT_PUBLISHJUNITRESULTS
2017-02-06T12:42:33.8812513Z ##[debug]loading INPUT_TARGETS
2017-02-06T12:42:33.8812513Z ##[debug]loading INPUT_TESTRESULTSFILES
2017-02-06T12:42:33.8812513Z ##[debug]loaded 16
2017-02-06T12:42:35.3187615Z Error: Failed which: Not found ant: null

/Magnus

CrossPlatform

Most helpful comment

@ericsciple, people are finding this error message pretty cryptic:
Error: Failed which: Not found ant: null

Can the task-lib's task.ts line 1003 supplement the error to output something more, like:
Error: Failed which: the tool was not found in the path: ant

All 10 comments

Hi,

Can you run ant from the command line? It looks like that ant is not in your PATH.

Hi,
Command line does not work but the agent identifies both ant and ANT_Home as capabilities, should not that be enough?

Hi @MagnusTim. Sorry for the trouble and disruption to your customer's build processes. There are two things affecting what you're seeing:

First, just as you noted above, when the build agent starts, it checks to determine whether it has the Ant "capability." Depending on which version of the agent you're running, it does this by looking for the ANT_HOME environment variable or for 'ant' in the path. It sounds like your agent found this capability. Having the Ant capability just registers this build agent as being compatible with builds that use the Ant task.

Second, when the build is executing, the Ant build task (source code here) simply expects 'ant' to be in the path. Can you please verify it's in the path? Sometimes people hit an issue where it's in the path for one user account of the OS, but not in the path for the account the build agent is running as.

You could also make sure you're running a newer version of the build agent (manually downloadable from here) in case that portion didn't get updated during your upgrade.

If you still have an issue, can you please send me your full build log? ([email protected])

Thanks,
David

Hi David,
Thanks for you answer

1. Agent
I am running the latest build agent version -2.111.1

2. The ant build task
Yest, ant is in the path.
Is there a way to get more debug information from the anttask.ts, I saw there where the tl.debug rows in the code, I have set the system.debug=True in the build.

I tried to runt the ant command in a command prompt from the java SDK\bin folder then I got it to work.
Like this, standing in c:\Program Files\Java\jdk1.8.0_101\bin
Running D:\ant\bin\ant.bat -buildfile D:\Builds\TestNewAgent_work\2\s\MySourcesfolders\build.xml, so it seems that is does not find Java SDK. I have Java JRE on the same macine as well.

I have also tried to add the Java SDK path to the JDK path under Advanced in the ant asks, still I get: Failed which: Not found ant: null

I will am sending the entire log to you.

/Magnus

xzhe and David, you where both right, it vas the PATH to D:\ANT\Bin that was missing for the Build user.

Thanks!

Thank you for reporting the issue regardless, @MagnusTim. Maybe the conversation here will be helpful to others.

The method for finding maven provides a bit more feedback, maybe something similar/better could be adopted for the ant task too. :)

@ericsciple, people are finding this error message pretty cryptic:
Error: Failed which: Not found ant: null

Can the task-lib's task.ts line 1003 supplement the error to output something more, like:
Error: Failed which: the tool was not found in the path: ant

makes sense

A year later and it still reports "Not found ant: null".
Thanks for having this thread available, I was able to easily fix the issue.

Was this page helpful?
0 / 5 - 0 ratings