java.io.IOException: Cannot run program "sh" - jenkins

I am trying to run postman collection in jenkins getting below error Could you please help on it . Thanks.
Running as SYSTEM
Building in workspace C:\Users.jenkins\workspace\Postman
[Postman] $ sh -xe C:\Users\AppData\Local\Temp\12\jenkins4131098184637934114.sh
The system cannot find the file specified
FATAL: command execution failed
Caused: java.io.IOException: Cannot run program "sh" (in directory "C:\Users.jenkins\workspace\Postman"): CreateProcess error=2, The system cannot find the file specified

The answer was provided here, you have two options:
On your {jenkinsUrl}/job/{jobName}/configure build step you can choose "Execute Windows batch command" rather than "Execute shell"
In Manage Jenkins -> Configure System -> Shell, set the shell path
as
C:\Windows\system32\cmd.exe

Related

cd, cat commands not execute in Jenkins

when i try to use cd, cat commands in jenkins job, it doesnot execute these commands.
I give all permission to that directory but jenkins show error.
CONSOLE OUTOUT:
Started by user Amrit Subedi Running as SYSTEM Building in workspace
/var/lib/jenkins/workspace/todolist-app [todolist-app] $ /bin/sh -xe
/tmp/jenkins4194062835107740167.sh
cd /home/amrit/Jenkins/docker /tmp/jenkins4194062835107740167.sh: 2: cd: can't cd to /home/amrit/Jenkins/docker Build step 'Execute shell'
marked build as failure Finished: FAILURE
Please tell me the solution, if you know its solution.
please try to add the following line at the beginning of your "Execute shell" Build steps :
#!/bin/sh

Error "$ cmd /c call C:\Windows\TEMP\jenkins6446000872510816227.bat The syntax of the command is incorrect."

Error "$ cmd /c call C:\Windows\TEMP\jenkins6446000872510816227.bat The syntax of the command is incorrect." while executing job for running JMeter test in Jenkins
Going to TEMP folder there was no jenkins6446000872510816227.bat file error aswell. What could be teh issue and what is the solution for this?
Expecting my job build be SUCESS but it is a failure due to this error
Your question doesn't have sufficient amount of details so we cannot troubleshoot your issue.
It's possible to run JMeter script in command-line non-GUI mode like:
c:\apps\jmeter\bin\jmeter.bat -n -t test.jmx -l result.jtl
It's possible to run Windows batch scripts in Jenkins
If it doesn't work for you first check that you can run JMeter test without issues in command-line non-GUI mode on the Jenkins build agent and then double check the syntax of your "Execute Windows batch command" section of the job.
More information: The Complete Guide to Continuous Integration With Jenkins

Jenkins can't find directory when executing shell command

I want to execute these shell command in my Jenkins job.
cd /Users/username/Desktop/JenkinsProject
javac Jenkins.java
java Jenkins
However when I try to build I get the error:
Running as SYSTEM
Building in workspace /Users/Shared/Jenkins/Home/workspace/JenkinsExample
[JenkinsExample] $ /bin/sh -xe /Users/Shared/Jenkins/tmp/jenkins2459427386874444762.sh
+ cd /Users/username/Desktop/JenkinsProject
/Users/Shared/Jenkins/tmp/jenkins2459427386874444762.sh: line 2: cd: /Users/username/Desktop/JenkinsProject: Not a directory
Build step 'Execute shell' marked build as failure
Gitcolony notification failed - java.lang.IllegalArgumentException: Invalid url:
Finished: FAILURE
It looks like it can't find the folder when running the commands with Jenkins?
If I dont use Jenkins but run the commands in my terminal everything works fine.

Jenkins throws "Executable not found in $PATH"

I have installed kompose in my Jenkins machine through CLI and it is successfully installed.
I am trying to build a job which uses this "kompose" executable but it fails with "Exectable not found in the $PATH" error.
Error:
+ skaffold init --compose-file docker-compose.yaml
time="2019-11-13T10:39:00Z" level=fatal msg="running kompose: exec: \"kompose\": executable file not found in $PATH"
Please let me know if I need to make anymore changes to communicate the executable to Jenkins
On your Jenkins job has executed, you can review its environment variables (on the left side of the job execution instance page)
Check the PATH value and see if it includes where you have installed kompose.
Check also which user is actually running Jenkins: its $PATH might differ from your current local user.

Process leaked file descriptors error on starting a batch command from JENKINS

Hi I am trying to execute batch command from Jenkins and getting the below error
"Process leaked file descriptors. See https://jenkins.io/redirect/troubleshooting/process-leaked-file-descriptors for more information"
I am trying to execute the command which starts the application , something like this "mch.bat openAPI start" . When I manually run this command it opens a new command window and returns the process ID but when the same command is executed from jenkins the process ID is returned as 0 with clean logs. Jenkins master is linux and slave is windows.
Thanks in advance,
Meghana SA

Resources