How to setup Jenkins for a Maven project.
What is Jenkins?
Jenkins is an open source automation tool written in Java with plugins built for Continuous Integration purpose. Jenkins is used to building and testing your software projects continuously making it easier for developers to integrate changes to the project, and making it easier for users to obtain a fresh build. It also allows you to continuously deliver your software by integrating with a large number of testing and deployment technologies.
With Jenkins, organizations can accelerate the software development process through automation. Jenkins integrates development life-cycle processes of all kinds, including build, document, test, package, stage, deploy, static analysis and much more.
Jenkins achieves Continuous Integration with the help of plugins. Plugins allow the integration of Various DevOps stages. If you want to integrate a particular tool, you need to install the plugins for that tool. For example it, Maven 2 project, Amazon EC2, HTML publisher etc.
Advantages of Jenkins include:
- It is an open source tool with great community support.
- It is easy to install.
- It has 1000+ plugins to ease your work. If a plugin does not exist, you can code it and share with the community.
- It is free of cost.
- It is built with Java and hence, it is portable to all the major platforms.
Now we look into How to setup Jenkins for a Maven project.:
Step 1-Starting Jenkins: which can be started via command line or web application server.
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)
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
–Xmx512m
–XX:MaxPermSize=128m
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.
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
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
-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”
-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”
3.configure the job as in the screenshot and don’t forget to save
Step6: Run the build(job) from home page and output should be.
Thanks for reading this article!
Comments
Post a Comment