muthukuru sekhar
muthukuru sekhar

Reputation: 11

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

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

Upvotes: 1

Views: 4018

Answers (2)

Moon_Sigma
Moon_Sigma

Reputation: 3

This works Fine for me : Instead of using sh 'your command', use bat 'your command' since your shell is cmd.exe on a Windows machine. You could also change your default shell in the Jenkins settings to use a Unix-based one, ex: using wsl.exe, then sh 'your command'...

stage('Build') {
    steps {
        echo 'Building Stage Start'
        bat './gradlew assemble'
        echo 'Building Stage End'
    }
}

Upvotes: 0

Anderson Paiva
Anderson Paiva

Reputation: 978

The answer was provided here, you have two options:

  1. On your {jenkinsUrl}/job/{jobName}/configure build step you can choose "Execute Windows batch command" rather than "Execute shell"

  2. In Manage Jenkins -> Configure System -> Shell, set the shell path as

    C:\Windows\system32\cmd.exe

Upvotes: 2

Related Questions