Builds fails on Bamboo Data Center Windows agent with error : 'sh' is not recognized as an internal command
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
This article covers a scenario where builds having script task with Interpreter as shell failed to run on Windows remote agents with error : 'sh' is not recognized as an internal command
Environment
The issue was seen on Bamboo version 9.2.7 but the solution would be applicable for any other supported version.
Diagnosis
Normally any script task with Interpreter as shell by default would run on Linux agents. If these scripts needs to be run on a Windows agent, you'll need to install a third-party tool like Git Bash, as by default Windows doesn’t natively support .sh files.
In absence of this third party tool, if these builds are run are on the Windows agent, you'll see below error
'sh' is not recognized as an internal command
Cause
Windows doesn’t natively support .sh files. To run such files, you typically need to install a third-party tool like Git Bash and edit the PATH variable correctly
Solution
- Please follow Git Bash to Install Git Bash on your Windows agent and validate if it is installed properly
- The gitbash binary resides in C:\Program Files\Git\bin, so you must include that in the PATH, please follow this external article for more details
C:\Program Files\Git\bin;
C:\Program Files\Git\mingw64\bin;
Please validate if the above path is correct for the agent where you are trying to run the builds
3. Please restart the agent machine and check if the build completes successfully