3

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"
2
  • Try dropping 1st / in path. Commented Apr 14, 2021 at 4:58
  • Actually that is parameter I receive from another yaml. Edited the path I receive. Commented Apr 14, 2021 at 5:00

2 Answers 2

10

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

Sign up to request clarification or add additional context in comments.

2 Comments

Have you checked my reply? Is it helpful?
Thanks for the response. Sorry for the delayed comment, It took sometime for me to test it out. This worked for me. Bash was not set up properly in terms of path. Either setting path in above method or using powershell instead for windows agent , both worked. I am unable to upvote the answer being the new user, but this answer worked for me !
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.