Jenkins supports Maven for building and testing a project in continuous integration. In this recipe, we will set up Jenkins to run tests from a Maven project.
Running tests with Jenkins and Maven needs both the tools installed on the machine. In this recipe, the SeleniumCookbook
project is used from the earlier Configuring Eclipse and Maven for Selenium WebDriver test development recipe.
This recipe refers to Subversion as the Source Code Management (SCM) tool for the SeleniumCookbook
project.
You can use various SCM tools along with Jenkins. If Jenkins does not support the SCM tool that you are using, please check the Jenkins plugin directory for specific SCM tool plugins.
http://localhost:8080
by default) in the browser window.Selenium Cookbook
in the Job name textbox.pom.xml
, and in the Goals and options textbox, enter clean test
, as shown in the following screenshot:The Selenium Cookbook project page displays the build history and links to the results, as shown in the following screenshot:
0 22 * * *
in the Schedule textbox, as shown in the following screenshot. This will trigger the build process every day at 10 p.m. and the test will run unattended:Using the Build a Maven2/3 Project option, Jenkins supports building and testing Maven projects.
Jenkins supports various SCM tools such as CVS and Subversion. To get the source code from SCM, specify the repository location and check out the strategy. Since Maven is used in this example, specify the path of root POM and Maven Goal.
While building the project, Jenkins gets the latest source from SCM to the Jenkins project workspace. It will then call Maven with specified goals. When the build process is complete, Jenkins gets the test results from Maven and displays these results on the project page.
One of the important features of Jenkins is that it automatically triggers the build, based on defined criteria. Jenkins provides multiple ways to trigger the build process under the Build Trigger configuration. Build Trigger can be set at a specific time. In the previous example, it was set to trigger the process every day at 10 p.m. This provides the ability to nightly run tests unattended, so that you can see the results the next morning.
3.22.71.220