1

I am trying to build a Jenkins Pipeline for my Spring Boot (Maven) project. It is all working fine. However, i am trying to run my Karate Framework related tests under my project. However my Karate tests are not written in src directory of the project.

Here is the project, that I am trying to build: https://github.com/shah-smit/spring-boot-karate-contract-testing

Here is my Jenkins File, that can be also found in the above repo:

pipeline{
    agent any

    stages {
        stage('Compile Stage'){
            steps {
                withMaven(maven: 'maven_3_6_3'){
                    sh 'mvn clean compile'
                }
            }
        }

        stage('Testing Stage'){
            steps {
                withMaven(maven: 'maven_3_6_3'){
                     sh 'mvn test'
                }
            }
        }

        stage('Package Stage'){
            steps {
                withMaven(maven: 'maven_3_6_3'){
                    sh 'mvn package'
                }
            }
        }

    }
}

Here is my pom.xml

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.1</version>
                <configuration>
                    <excludes>
                        <exclude>karate/**/*.java</exclude>
                    </excludes>
                    <includes>
                        <include>com/**/*.java</include>
                    </includes>
                </configuration>
            </plugin>
        </plugins>
    </build>
Smit
  • 2,078
  • 2
  • 17
  • 40

1 Answers1

0

However my Karate tests are not written in src directory of the project.

And this is your problem. Don't try to go against the Maven conventions, they are like that for good reasons.

I suggest you look at this example (also for Spring boot) and use the same directory structure and naming conventions:

https://github.com/Sdaas/hello-karate

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Thanks. But I understand that is out of convention (at least against Maven). However is there a way to configure? – Smit Mar 22 '20 at 07:24
  • 1
    @Smit I certainly don't know the answer - maybe it is possible, try read the Maven documentation - but this response of mine should give you a hint as to why this is a bad idea :) – Peter Thomas Mar 22 '20 at 07:25