How to Tests for a specific module under a project in Jenkins through maven?

continuous-integration, jenkins, maven, maven-2

Solution

Just run from the root path:

mvn -pl :submodule test

protip: `mvn --help`

Problem

I use Jenkins to build my project which has multiple modules. This project has a root pom.xml which build all the modules under that project. I specify this pom.xml as the root POM. Now I want to run tests as a "post-build step". But, I don't want to run all the tests under all modules. I want to run tests only under a specific module. I tried using the shell command to change the directory to the module for which tests has to be run and then trigger maven. I also tried using the -f switch to specify the pom.xml for that particular module. Both of these steps are not working. Please help me guys in resolving this problem. Thanks

Original source