When trying to run a simple Azure CLI Task in my ubuntu-based Azure DevOps pipeline I get the following error message:
##[error]Script failed with error: Error: Unable to locate executable file:
'/home/vsts/work/_temp/azureclitaskscript1637831708745.bat'.
Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable.
Also check the file mode to verify the file is executable.
If I'm reading this correctly the inline script is not being found, right? What am I missing here? Here's the full YAML:
trigger:
- main
- dev
pool:
vmImage: ubuntu-latest
steps:
- task: AzureCLI@2
inputs:
azureSubscription: 'My Subscription Name'
scriptType: 'batch'
scriptLocation: 'inlineScript'
inlineScript: 'az --version'
CodePudding user response:
You're running your task on Linux, you can't use batch
there, you'll need to pick pscore
or bash
instead, or switch to a windows-latest
vmImage.
Script Type*: Select the type of script to be executed on the agent. Task supports four types: Batch / Shell / PowerShell / PowerShell Core scripts, default selection being empty. Select Shell/PowerShell Core script when running on Linux agent or Batch/PowerShell/PowerShell Core script when running on Windows agent. PowerShell Core script can run on cross-platform agents (Linux, macOS, or Windows)
The actual strings to pass to the arguments can be found in the task.json. It looks like the task doesn't do any validation on these fields, causing this weird error situation.
"options": {
"ps": "PowerShell",
"pscore": "PowerShell Core",
"batch": "Batch",
"bash": "Shell"
}