1
votes

I get the following error if I run my azure devops pipeline:

##[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 check the file 
mode to verify the file is executable.

I tried it with my self hosted agent and with microsoft hosted agent, both of them have the same error.

Here is my pipeline:

trigger:
 - master

pool:
  vmImage: 'ubuntu-latest'

steps:
 - script: 
    echo Starting the build
    ./gradlew build
   displayName: 'Build
2

2 Answers

1
votes

You need to set the workingDirectory for the script like documnted here: Docs

- script: # script path or inline
  workingDirectory: #
  displayName: #

For example if you have a repository with a structure like this:

RepoName
 - Folder1
   - scriptToRun
 - Folder2

The value for workingDirectory would be:

- script: ./scriptToRun
  workingDirectory: '$(Build.SourcesDirectory)/Folder1'
  displayName: 'Build'

Or you can probably skip the workingDirectory and give a full path to the script. Note also tht this example is for a single repository checkout. If you checkout multiple repos the path would be different.

0
votes

I had the same problem, initially I had given my self-hosted agent, a PAT with access to the Agent Pools Read/Manage permission, as this is what it states in the docs, and then I started getting this error, even though bash was clearly in my PATH environment variable.

I then removed the agent, added it back, and this time gave it a PAT with Full Access.

I no longer receive the bash error.