Wednesday 5 September 2018

Job Creation In Jenkins for Maven Project

Jenkins Job Creation for maven project deploying in Tomcat

Question:How to configure a Jenkins JOB for automatically building a maven application and deploying in Tomcat server?

After Jenkins Installation in windows OS
For Jenkins installation please refer Jenkins installation page

STEP - 1


When we will hit the request as http://localhost:8080, Below screen will be displayed in browser-




STEP - 2


Open the file available in below default location
C:\Program Files x86)\Jenkins\secrets\initialAdminPassword

The initialAdminPassword file will contain secret key.

After placing the secret key and hitting in the continue button then next page will be shown as below


STEP - 3


Default plugin installation page will appear like below:



STEP - 4


In the next page it will ask for creation of username and password, try to skip this page and click on option Continue as admin.

After clicking on the Continue as admin link, the next page will be shown as below:



STEP - 5


After clicking on Start using Jenkins button, the page will be shown as below:



STEP - 6

Click on New Item link, below screen will appear



STEP - 7

Enter the Item Name as MavenDemo, then click on Maven Project then click on OK, below page will appear:




STEP - 8


Click on Source Code Management tab and click on Subversion



STEP - 9


After that click on Build Triggers tab and select Poll SCM, then enter the appropriate value for polling(as schedular) to check for SVN commit. Value are in Crone expression format as below. specify scheduler. This will check the svn repository at specific interval or time and if there is any change in code, it immediately starts build.

* * * * * = minute hour day month day
i.e. :- H/5 * * * * :- poll scm at every 5 minutes



STEP - 10


Now select build tab, use pom.xml value as Root POM



STEP - 11


In Post Steps, select Run only if build succeeds option. Then Select Post-Build Actions tab and select Deploy ear/war to a container, if that option is not there then we needs to install a plugin for that. The plugin name is Deploy ear/War to Container and you can find that in Manage Jenkins options(Available Plugin). For Container select Tomcat 7, if you want to configure Glassfish, Jboss that option is also available here.



STEP - 12


We can also add windows or shell script commands in Post Steps tab. Here I am adding windows service named as Tomcat7(servicename)




Note:- We can check this service name in windows -> services -> Running Tomcat Service -> then click and select properties.

No comments:

Post a Comment