user15338350
user15338350

Reputation: 293

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"

Upvotes: 3

Views: 7816

Answers (2)

Sandeep Negi
Sandeep Negi

Reputation: 27

Solution:

As mentioned in the above solution we need to add the path of the bash in the windows machine in which agent is running.

In my case the Windows machine that is running agent, there is no git bash so

Steps :

  1. Install the git bash in the remote machine
  2. Then add the path in the environment variable
  3. Restart the agent
  4. Window + R --> services.msc --> search for the Agent and restart it
  5. Then again try to run the bash task after some time since sometimes it will take some time to again added to the Agent Pool,

You can also try running the command inline ,

enter image description here

Upvotes: 0

Cece Dong - MSFT
Cece Dong - MSFT

Reputation: 31075

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

Upvotes: 10

Related Questions