javagithubjenkinsselenium-chromedrivercucumber

When I try to run my cucumber file on Jenkins, Jenkins looks at my local directory instead of GitHub


I am running Jenkins on my local machine from port 8080, the pipeline is connected to my GitHub through the plugin and I have confirmed that Jenkins can see my Jenkinsfile on my repo. There is a step in my Jenkinsfile to run a cucumber feature

pipeline {
    agent any

    stages {

        stage('Build & Run Cucumber Tests') {
            
            steps {
                
                dir ('DeltaFlight'){
                    
                // For Maven projects:
                sh 'mvn clean test -Dcucumber.optioms="@login"' 
                // For Gradle projects:
                // sh './gradlew clean test -Dcucumber.filter.tags="@your_tag"'
                
                }
            }
        }

        stage('Publish Cucumber Reports') {
            steps {
                // Ensure the Cucumber reports plugin is installed in Jenkins
                cucumber buildStatus: 'UNSTABLE', fileIncludePattern: '**/*.json'
            }
        }
    }
}

But when it gets to the step

dir ('DeltaFlight'){
                    
                // For Maven projects:
                sh 'mvn clean test -Dcucumber.optioms="@login"' 
                // For Gradle projects:
                // sh './gradlew clean test -Dcucumber.filter.tags="@your_tag"'
                
                }

I get the error

Cannot run program "sh" (in directory "C:\ProgramData\Jenkins.jenkins\workspace\Selenium2withGit\DeltaFlight"):

which is my local file not system not GitHub.

Here is a picture of the Jenkins error

enter image description here

and here is my GitHub file structure

enter image description here

I want to run the feature file in my GitHub LoginPageNCS.feature not my local machine.


Solution

  • The error msg contains:

    Cannot run program "sh" ... CreateProcess error ... The system cannot find the file specified
    

    Usually there is no sh on Windows (though, IIRC, Jenkins came with its own internal sh package in the past. But that might be wrong remembrance or might have changed.) So, try it with bat rather than sh or install MSYS and and add its \bin folder to your PATH.

    BTW, please consider Discourage screenshots of code and/or errors.