Search code examples
windowsjenkinsjenkins-plugins

Jenkins cannot recognize sh.exe although added to path


I am trying to run a pipeline with sh instead of bat on Windows.

I have added the following paths in the global properties:

C:\Program Files\Git\usr\bin
C:\Program Files\Git\bin 

but it still does not work.

When I run the pipeline, I get the following error message:

[pipeline] sh
/usr/bin/sh: C:\Program Files\Git\bin\sh.exe: Command not found
[pipeline] }

Note that the file sh.exe is located in the folder C:\Program Files\Git\bin\

However, if I use a Freestyle project with Execute Shell, it works correctly.

What else can I do to fix the problem?


Solution

  • It turns out that the space in Program Files was the one that was causing problems when trying to run the pipeline. Therefore sh.exe was not found in C:\Program Files\Git\bin\.

    So I had to move Git\bin location somewhere else where there are no spaces in the path.