Your Jenkins controller is running on Windows.  Windows uses batch and 
powershell for its command line scripting.

If you want to run a shell script, add an agent on an operating system that 
supports bash.  That could be a Linux Docker based agent running in Docker 
on your Windows computer.  It could be an agent on a Linux computer.  It 
could be an agent on macOS, FreeBSD, or OpenBSD.

In any case, you should add agents to your controller so that you are not 
running jobs on the controller.

Mark Waite

On Thursday, August 12, 2021 at 9:00:28 AM UTC-6 you wrote:

> Hello everyone,
>
> How can I execute shell scripts from jenkins? 
>
> I have the below code in "Execute Shell" command
> ""
> #!/bin/bash
> echo "hello"
>
> Received the following Error Msg  in the console.
>
> Running as SYSTEM Building on master in workspace 
> C:\Users\crnat\.jenkins\workspace\ssh-task-test [ssh-task-test] $ /bin/bash 
> C:\Users\crnat\AppData\Local\Temp\jenkins563122492098989130.sh The system 
> cannot find the file specified FATAL: command execution failed 
> java.io.IOException: CreateProcess error=2, The system cannot find the file 
> specified at java.lang.ProcessImpl.create(Native Method) at 
> java.lang.ProcessImpl.<init>(Unknown Source) at 
> java.lang.ProcessImpl.start(Unknown Source) Caused: java.io.IOException: 
> Cannot run program "/bin/bash" (in directory 
> "C:\Users\crnat\.jenkins\workspace\ssh-task-test"): CreateProcess error=2, 
> The system cannot find the file specified at 
> java.lang.ProcessBuilder.start(Unknown Source) at 
> hudson.Proc$LocalProc.<init>(Proc.java:252) at 
> hudson.Proc$LocalProc.<init>(Proc.java:221) at 
> hudson.Launcher$LocalLauncher.launch(Launcher.java:996) at 
> hudson.Launcher$ProcStarter.start(Launcher.java:508) at 
> hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:144) at 
> hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:92) at 
> hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at 
> hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:803)
>  
> at hudson.model.Build$BuildExecution.build(Build.java:197) at 
> hudson.model.Build$BuildExecution.doRun(Build.java:163) at 
> hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:513) 
> at hudson.model.Run.execute(Run.java:1906) at 
> hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at 
> hudson.model.ResourceController.execute(ResourceController.java:97) at 
> hudson.model.Executor.run(Executor.java:429) Build step 'Execute shell' 
> marked build as failure Finished: FAILURE
>
>
> Thanks,
> Poo
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/a48954e6-e1c7-48c1-8605-caf7479c2228n%40googlegroups.com.

Reply via email to