{"id":24280,"date":"2015-07-29T13:27:34","date_gmt":"2015-07-29T07:57:34","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=24280"},"modified":"2017-09-07T17:34:57","modified_gmt":"2017-09-07T12:04:57","slug":"how-to-setup-jenkins-for-a-maven-project","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/how-to-setup-jenkins-for-a-maven-project\/","title":{"rendered":"How to setup Jenkins for a Maven project"},"content":{"rendered":"<p>This blog post shows how to configure maven project in Jenkins. Follow these steps for\u00a0Jenkins Maven project configuration:<\/p>\n<h2>Step 1 &#8211; Starting Jenkins<\/h2>\n<p>a) Download Jenkins Zip file and extract it(i have downloaded for windows as i am setting it up on windows7)<\/p>\n<p>b) In cmd go to the path you have extracted Jenkins (eg.C:\\Program Files (x86)\\Jenkins)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-24287 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/07\/Image1-CMD-screen.png\" alt=\"jenkins maven configuration\" width=\"597\" height=\"182\" \/><\/p>\n<p>c) To start the Jenkins, run the command jenkins.exe start<br \/>\n-To restart the Jenkins: Jenkins.exe\u00a0 restart<br \/>\n-To stop the Jenkins: Jenkins.exe\u00a0 stop<\/p>\n<p>d) By default, it will open up on 8080 port as \u00a0localhost:8080 (make sure nothing else is running on port 8080)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-24288 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/07\/Image2-JenkinsStartUpScreen.png\" alt=\"jenkins maven build screen\" width=\"627\" height=\"434\" \/><\/p>\n<h2>Step 2 &#8211; Creating and configuring user on Jenkins<\/h2>\n<p>a) To create a user go to Manage Jenkins-&gt;Manage Users-&gt;Create User-&gt;Provide the required information<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-24294 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/07\/Untitled.png\" alt=\"how to configure maven project in jenkins\" width=\"632\" height=\"237\" \/><\/p>\n<p>b) Go to Manage Jenkins-&gt;Configure Global Security<br \/>\n-Check Enable security<br \/>\n-In Security Realm, select Jenkins own user database and check Allow users to sign up<br \/>\n-In authorization, there are multiple options select as per requirement<br \/>\n-Save once done<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-24296 size-full\" style=\"line-height: 1.714285714; font-size: 1rem;\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/07\/UntitledGCS.png\" alt=\"jenkins maven project configuration\" width=\"619\" height=\"371\" \/><\/p>\n<h2>Step 3 &#8211; Configuring System<\/h2>\n<p>a) Go to Manage Jenkins-&gt;Configure System<\/p>\n<p>b) Configure JDK<br \/>\n-Give the JDK name<br \/>\n-JAVA_HOME : C:\\Program Files\\Java\\jdk1.7.0_45<\/p>\n<p>c) Maven configuration<br \/>\n-Give a maven name<br \/>\n-MAVEN_HOME : C:\\apache-maven-3.2.5\\apache-maven-3.2.5-bin\\apache-maven-3.2.5<\/p>\n<p>d) Global Maven_OPTS<br \/>\n&#8211;Xmx512m<br \/>\n&#8211;XX:MaxPermSize=128m<\/p>\n<p>e) Save once done<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-24291 size-full\" style=\"line-height: 1.714285714; font-size: 1rem;\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/07\/Image5-configureSystem.png\" alt=\"jenkins maven project configuration\" width=\"632\" height=\"634\" \/><\/p>\n<h2>Step 4 &#8211; Adding Plugins<\/h2>\n<p>a) Go to Manage Jenkins-&gt;Add Plugins<\/p>\n<p>b) Install the plugins which are required, Eg. GIT client plugin: which Shared library plugin for other Git related Jenkins plugins,\u00a0 GIT plugin: This plugin integrates GIT with Jenkins etc.<\/p>\n<h2>Step 5 &#8211; Creating jobs<\/h2>\n<p>a) Go to New Items-&gt;Give a project name in &#8220;Item name&#8221; field-&gt;select Maven project-&gt;click OK<\/p>\n<p>b) Now configure the job<br \/>\n-Provide the description<br \/>\n-In Source Code Management, there are options for CVS project, Git etc,\u00a0 select the one which is required<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-24292 size-full\" style=\"line-height: 1.714285714; font-size: 1rem;\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/07\/Image7-JobConfigure1.png\" alt=\"jenkins maven plugin creating jobs\" width=\"632\" height=\"331\" \/><\/p>\n<p>&#8211; In Build Triggers, there are multiple options like \u201cBuild when a change is pushed to GitHub\u201d, \u201cPoll SCM\u201d, \u201cBuild whenever a SNAPSHOT dependency is built\u201d etc, select the required one<br \/>\n&#8211; Give the path of your pom.xml file in Build Root POM<br \/>\n&#8211; Give \u201cGoals and options\u201c \u00a0take a use case where the requirement is to install the code then give \u201dclean install\u201d<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-24285 size-full\" style=\"line-height: 1.714285714; font-size: 1rem;\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/07\/Image7-JobConfigure2.png\" alt=\"jenkins maven integration with jobs confguration\" width=\"620\" height=\"202\" \/><\/p>\n<p>c) Configure the job as in the screenshot and don&#8217;t forget to save<\/p>\n<p>d) In the same way, create another job(4503_deploy)<\/p>\n<p>e) Suppose the requirement is creating two jobs, one(4502_deploy) for deploying the code on author instance 4502 and if it&#8217;s built is successful than it should run its downstream job(4503_deploy) for deploying code on publishing instance.<\/p>\n<p>f) Now configure the job &#8220;4502_deploy&#8221;, In Post Steps select &#8220;Run only if build succeeds&#8221;<\/p>\n<p>g) In Post Build Action, add post build action and give the job name(4503_deploy) in &#8220;Projects to build<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-24286 size-full\" style=\"line-height: 1.714285714; font-size: 1rem;\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/07\/Image7-JobConfigure3.png\" alt=\"configure Jenkins Maven Job\" width=\"625\" height=\"279\" \/><\/p>\n<h2>Step 6 &#8211; Build the jobs<\/h2>\n<p>Now build the job &#8220;4502_deploy&#8221;, on successful completion &#8220;4503_deploy&#8221; will trigger automatically and hopefully, jobs will be successful!!!<\/p>\n<p>Following these steps above, you will be able to configure your Maven project over Jenkins.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This blog post shows how to configure maven project in Jenkins. Follow these steps for\u00a0Jenkins Maven project configuration: Step 1 &#8211; Starting Jenkins a) Download Jenkins Zip file and extract it(i have downloaded for windows as i am setting it up on windows7) b) In cmd go to the path you have extracted Jenkins (eg.C:\\Program [&hellip;]<\/p>\n","protected":false},"author":189,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":95},"categories":[1],"tags":[2053,1682,2055,1340,2054],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/24280"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/189"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=24280"}],"version-history":[{"count":5,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/24280\/revisions"}],"predecessor-version":[{"id":51759,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/24280\/revisions\/51759"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=24280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=24280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=24280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}