How To Execute Maven Project Using Jenkins | Software Testing Material

Earlier, we had learnt How To Install Maven in Eclipse and then we learnt How To Create Maven Project in Eclipse. Today in this post, we are going to see How To Execute Maven Project Using Jenkins. To do this, we need to have the following

i. Maven – Check this post on Installation of Maven.
ii. Maven Project – Check this post on Creating Maven Project.
ii. Jenkins – Check this post on Installation of Jenkins.

Firstly install Maven in Eclipse IDE and create a Maven Project. Next, open Jenkins and create a new Job to execute Maven Project using Jenkins.

Execute Maven Project Using Jenkins:

In this article, we see how to execute maven project using jenkins.

Click on New Item link to create a job on Jenkins

Enter an item name (here I am adding a name ‘MavenProject’) and click on FreeStyle Project and click on OK

Scroll down to ‘Build‘ option. Click on ‘Add Build Step‘ and choose the value ‘Invoke top-level Maven targets‘ from the drop down list.

Enter Goals “clean install

Enter POM path (in my case the path is D:\STM\STMBlog\workspace\MavenProject\pom.xml)

Click on ‘Apply‘ and ‘Save


We have created a new project ‘MavenProject‘ with the configuration to execute Maven Project using Jenkins. You could see in the below screenshot.


Let’s execute it now. Click on ‘Build Now‘ button. It will invoke pom.xml.

Right click on Build Number (here in my case it is #1) and click on Console Output to see the result.

You could see Build Status ‘Success’ on Console Output.

This way, we could execute Maven Project using Jenkins. We could generate Extent Reports after the completion of execution. This we see in the next post.

Run Maven Project Using Jenkins

Rajkumar SM is a founder of SoftwareTestingMaterial. He is a certified Software Test Engineer by profession and blogger & youtuber by choice. He has an extensive experience in the field of Software Testing. He writes here about Software Testing which includes both Manual and Automation Testing. He loves to be with his wife and cute little kid 'Freedom'.

9 thoughts on “How To Execute Maven Project Using Jenkins | Software Testing Material”

  1. Nice post Raj!. Can you please update the post by pulling the maven project from GIT and execute it.

    • Sure Bhargav, will do it ASAP.

  2. Hello Mahajan,
    Below error i am getting while running sample project throw Jenkins
    Same code working when do run as Maven Test or using Testng
    Please help .

    [INFO] Scanning for projects…
    [INFO] ————————————————————————
    [INFO] Building LVQ 0.0.1-SNAPSHOT
    [INFO] ————————————————————————
    [INFO] — maven-clean-plugin:2.5:clean (default-clean) @ LVQ —
    [INFO] Deleting D:\Ajmal_Automation\LVQUALITY\LVQ\target
    [INFO] — maven-resources-plugin:2.6:resources (default-resources) @ LVQ —
    [INFO] Using ‘UTF-8’ encoding to copy filtered resources.
    [INFO] skip non existing resourceDirectory D:\Ajmal_Automation\LVQUALITY\LVQ\src\main\resources
    [INFO] — maven-compiler-plugin:3.5.1:compile (default-compile) @ LVQ —
    [INFO] Changes detected – recompiling the module!
    [INFO] Compiling 8 source files to D:\Ajmal_Automation\LVQUALITY\LVQ\target\classes
    [INFO] — maven-resources-plugin:2.6:testResources (default-testResources) @ LVQ —
    [INFO] Using ‘UTF-8’ encoding to copy filtered resources.
    [INFO] skip non existing resourceDirectory D:\Ajmal_Automation\LVQUALITY\LVQ\src\test\resources
    [INFO] — maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ LVQ —
    [INFO] Changes detected – recompiling the module!
    [INFO] Compiling 2 source files to D:\Ajmal_Automation\LVQUALITY\LVQ\target\test-classes
    [INFO] — maven-surefire-plugin:2.19.1:test (default-test) @ LVQ —

    T E S T S
    Running TestSuite

    … TestNG 6.9.10 by C‚dric Beust ([email protected])

    Running in Firefox browser
    log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
    log4j:WARN Please initialize the log4j system properly.
    Running in Chrome browser
    Starting ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) on port 33929
    Only local connections are allowed.
    Dec 13, 2017 3:10:15 PM org.openqa.selenium.remote.ProtocolHandshake createSession
    INFO: Detected dialect: OSS
    Tests run: 12, Failures: 1, Errors: 0, Skipped: 6, Time elapsed: 20.215 sec <<< FAILURE! – in TestSuite
    launchBrowser( Time elapsed: 13.575 sec <<< FAILURE!
    Process unexpectedly closed with status: 0
    Build info: version: '3.7.0', revision: '2321c73', time: '2017-11-02T22:22:35.584Z'
    System info: host: 'VDC01DD2120', ip: '', 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_45'
    Driver info: driver.version: FirefoxDriver
    remote stacktrace: stack backtrace:
    0: 0x4821c4 –
    1: 0x482933 –
    2: 0x445159 –
    3: 0x44c838 –
    4: 0x43026a –
    5: 0x40ba4e –
    6: 0x4119b9 –
    7: 0x6d2c89 –
    8: 0x426006 –
    9: 0x6cd490 –
    10: 0x775659cd – BaseThreadInitThunk

    Results :

    Failed tests:
    LoginPagesTest>BaseTest.launchBrowser:33 ¯ WebDriver Process unexpectedly clos…

    Tests run: 7, Failures: 1, Errors: 0, Skipped: 1

    [INFO] ————————————————————————
    [INFO] ————————————————————————
    [INFO] Total time: 23.038 s
    [INFO] Finished at: 2017-12-13T15:10:21+05:30
    [INFO] Final Memory: 23M/219M
    [INFO] ————————————————————————
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project LVQ: There are test failures.
    [ERROR] Please refer to D:\Ajmal_Automation\LVQUALITY\LVQ\target\surefire-reports for the individual test results.
    [ERROR] -> [Help 1]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1]
    Build step ‘Invoke top-level Maven targets’ marked build as failure
    Finished: FAILURE

    • Hi Share your pom.xml file

  3. Hi Raj,

    I have a doubt regarding triggering the Builds ie Test execution through Jenkins. Why i am not able to see the automated TC script run through naked eyes ?. All i can see is a console output. saying build is success

    • Try to run the Jenkins jar from the command line..

      • If you have installed jenkins.. try this out..
        Go to run and type Services.msc
        Click enter..
        Select Jenkins – Properties – Logon – Allow service to interact with desktop.. restart the service..

  4. Raj can you please add video on running of maven project on jenkins , im fallowing all your video, its really helping me lot .
    I failed to create build in jenkins can you please give me solution.

    • Hi Pooja, will try to do it. For time being follow Continuous Integration post on my blog.. search using search bar which is on the sidebar. Thanks.

Leave a Comment

Share via
Copy link
Powered by Social Snap