How to setup Jenkins for a Maven project.

29 / Jul / 2015 by Dipti 2 comments

Step 1-Starting Jenkins
1.Download Jenkins Zip file and extract it(i have downloaded for windows as i am setting it up on windows7)
2.In cmd go to the path you have extracted Jenkins (eg.C:\Program Files (x86)\Jenkins)

Image1-CMD screen

3.To start the jenkins, run the command jenkins.exe start
-To restart the Jenkins: Jenkins.exe  restart
-To stop the Jenkins: Jenkins.exe  stop
4.By default it will open up on 8080 port as  localhost:8080 (make sure nothing else is running on port 8080)


Step 2-Creating and configuring user on Jenkins
1.To create a user go to Manage Jenkins->Manage Users->Create User->Provide the required information


2.Go to Manage Jenkins->Configure Global Security
-Check Enable security
-In Security Realm, select Jenkins own user database and check Allow users to sign up
-In authorization, there are multiple options select as per requirement
-Save once done


Step 3-Configuring System
1.Go to Manage Jenkins->Configure System
2.Configure JDK
-Give the JDK name
-JAVA_HOME : C:\Program Files\Java\jdk1.7.0_45
3.Maven configuration
-Give a maven name
-MAVEN_HOME : C:\apache-maven-3.2.5\apache-maven-3.2.5-bin\apache-maven-3.2.5
4.Global Maven_OPTS
5.Save once done


Step 4-Adding Plugins
1.Go to Manage Jenkins->Add Plugins
2.Install the plugins which are required, eg. GIT client plugin: which Shared library plugin for other Git related Jenkins plugins,  GIT plugin :This plugin integrates GIT with Jenkins etc.

Step 5-Creating jobs
1.Go to New Items->Give a project name in “Item name” field->select Maven project->click OK
2.Now configure the job
-Provide the description
-In Source Code Management, there are options for CVS project, Git etc,  select the one which is required

Image7-JobConfigure1 -In Build Triggers, there are multiple options like “Build when a change is pushed to GitHub”, “Poll SCM”, “Build whenever a SNAPSHOT dependency is built” etc, select the required one
-Give the path of your pom.xml file in Build Root POM
– Give “Goals and options“  take a use case where the requirement is to install the code then give ”clean install”Image7-JobConfigure2

3.configure the job as in the screenshot and don’t forget to save
4.In the same way create another job(4503_deploy)
5.Suppose the requirement is creating two jobs, one(4502_deploy) for deploying the code on author instance 4502 and if it’s build is successful than it should run its downstream job(4503_deploy) for deploying code on publish instance.
6.Now configure the job “4502_deploy”, In Post Steps select “Run only if build succeeds”
7.In Post Build Action, add post build action and give the job name(4503_deploy) in “Projects to build


Step 6-Build the jobs
1.Now build the job “4502_deploy”, on successful completion “4503_deploy” will trigger automatically and hopefully jobs will be successful!!!


comments (2)

Leave a comment -