Search code examples
azure-devopstfsazure-pipelinesmaven-3azure-pipelines-tasks

Azure Pipelines Command Line Task: "Cannot bind argument to parameter 'LiteralPath' because it is an empty string"


I have pipeline agents installed on multiple machines and each one has a .env file, since each one has slightly different local values for the environment vars. One of them is not working, however. The agent was installed and configured the same way on every machine.

In my pipeline I have a command line task that works in the $(Build.Repository.LocalPath) folder. When it runs the command mvn clean install -DskipTests=true, I get the error thrown in the title about an empty string. In the file, I've made sure that M2_HOME is pointing to the maven directory and that Java and Maven are added to "Path". The formatting looks like this, and it is the same format for every .env file on all the machines. Any clues?

JAVA_HOME=C:\\softwarebuild\\soft\\java\\jdk-11.0.2

M2_HOME=C:\\Users\\[redacted]\\.m2\\wrapper\\dists\\apache-maven-3.6.0-bin\\3rgjh30jneo7541hun7uggltkb\\apache-maven-3.6.0

Path=JAVA_HOME;M2_HOME\\bin

EDIT: I ran with system diagnostics turned on. Is it telling me it can't find cmd.exe? The first line of "cmdline.ps1" is just [CmdletBinding()]:

2022-01-24T18:20:55.0366255Z Script contents:
2022-01-24T18:20:55.0380447Z mvn clean install -DskipTests=true
2022-01-24T18:20:55.0643303Z ##[debug]AGENT_VERSION: '2.196.2'
2022-01-24T18:20:55.0803490Z ##[debug]AGENT_TEMPDIRECTORY: 
'C:\agents\_work\_temp'
2022-01-24T18:20:55.0844911Z ##[debug]Asserting container path exists: 
'C:\agents\_work\_temp'
2022-01-24T18:20:55.1197587Z ##[debug]Leaving 
C:\agents\_work\_tasks\CmdLine_d9bafed4-0b18-4f58-968d- 
86655b4d2ce9\2.198.0\cmdline.ps1.
2022-01-24T18:20:55.1295729Z ##[debug]Caught exception from task script.
2022-01-24T18:20:55.1356782Z ##[debug]Error record:
2022-01-24T18:20:55.2573018Z ## 
[debug]C:\agents\_work\_tasks\CmdLine_d9bafed4-0b18-4f58-968d- 
86655b4d2ce9\2.198.0\cmdline.ps1 : Cannot bind argument to parameter 
'LiteralPath' because it is an empty string.
2022-01-24T18:20:55.2589074Z ##[debug]At line:1 char:1
2022-01-24T18:20:55.2616630Z ##[debug]+ . 
'C:\agents\_work\_tasks\CmdLine_d9bafed4-0b18-4f58-968d-86655b4d2ce ...
2022-01-24T18:20:55.2641009Z ##[debug]+ 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-01-24T18:20:55.2664818Z ##[debug]    + CategoryInfo          : 
InvalidData: (:) [cmdline.ps1], ParameterBindingValidationException
2022-01-24T18:20:55.2688247Z ##[debug]    + FullyQualifiedErrorId : 
ParameterArgumentValidationErrorEmptyStringNotAllowed,cmdline.ps1
2022-01-24T18:20:55.2711281Z ##[debug] 
2022-01-24T18:20:55.2751043Z ##[debug]Script stack trace:
2022-01-24T18:20:55.2827845Z ##[debug]at <ScriptBlock>, 
C:\agents\_work\_tasks\CmdLine_d9bafed4-0b18-4f58-968d- 
86655b4d2ce9\2.198.0\cmdline.ps1: line 42
2022-01-24T18:20:55.2852703Z ##[debug]at <ScriptBlock>, <No file>: line 
1
2022-01-24T18:20:55.2878438Z ##[debug]at <ScriptBlock>, <No file>: line 
22
2022-01-24T18:20:55.2903959Z ##[debug]at <ScriptBlock>, <No file>: line 
18
2022-01-24T18:20:55.2932146Z ##[debug]at <ScriptBlock>, <No file>: line 
1
2022-01-24T18:20:55.2974680Z ##[debug]Exception:
2022-01-24T18:20:55.3223441Z ## 
[debug]System.Management.Automation.ParameterBindingValidationException: 
Cannot bind argument to parameter 'LiteralPath' because it is an empty 
string.

Solution

  • I was missing an evironment variable called "ComSpec". The script was expecting to find that variable, with the value of the path pointing to cmd.exe.