Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I let jenkins run `bash` command on windows?

I have setup a jenkins server on windows10 pro and installed ubuntu bash on the system. And I created a Executable windows batch command and put the command bash -c ls there. When executing this job I got below error:

c:\jenkins\workspaces>bash -c ls 
'bash' is not recognized as an internal or external command,
operable program or batch file.

It says that bash is not recognized as an internal or external command. Then I tried to use the absolute path but still not work. The error is shown as below:

c:\jenkins\workspaces>C:\Windows\System32\bash.exe -c ls 
'C:\Windows\System32\bash.exe' is not recognized as an internal or external command,
operable program or batch file. 

I can run the command manually on windows. How can I configure this on jenkins? I need to run the build command from windows normal command window and in my build script it needs to launch a process inside bash.

like image 518
Joey Yi Zhao Avatar asked Jun 21 '17 03:06

Joey Yi Zhao


People also ask

How do I run a bash command in Windows?

To access the shell, simply type 'bash' in the Windows command prompt, and everything is good to go.

Can I run Bash script on Windows?

With the arrival of Windows 10's Bash shell, you can now create and run Bash shell scripts on Windows 10. You can also incorporate Bash commands into a Windows batch file or PowerShell script.


1 Answers

You could install MsysGit, which includes bash, and in Jenkins you have to set the shell executable, which is the path to the sh.exe

You could also install cygwin, but i think this uses high amount of RAM for just running bash scripts.

like image 133
Shaqil Ismail Avatar answered Oct 12 '22 23:10

Shaqil Ismail