Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to locate executable file: 'bash" error : Inline script using Bash@3 Azure DevOps task

I was getting below error on using a self hosted windows agent.

##[error]Unable to locate executable file: 'bash'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.

Here is my pipeline - Goal of task was to get the filename alone from the whole filePath and to use this filename in further tasks.

trigger:
 - master

parameters:
 project: './test/abc/UnitTest.proj'

pool: self-hosted-windows

steps:
 - task: Bash@3
   inputs:
     targetType: 'inline'
     script: |
       input="${Parameters.project}"
       file_name_with_ext="${input##*/}"
       file_only="${file_name%.*}"
       echo "File : $file_only"
like image 447
user15338350 Avatar asked May 28 '26 00:05

user15338350


1 Answers

The issue is you didn't add bash command folder in the PATH of environment variable on the agent machine.

You need to login the agent machine, and then add "C:\Program Files\Git\bin" to the Path of Environment Variables, then restart the agent service.

enter image description here

like image 110
Cece Dong - MSFT Avatar answered Jun 01 '26 00:06

Cece Dong - MSFT