Technology: Jenkins is the most powerful and most preferred to use application for continuous integration, and continuous delivery of projects. As Jenkins is web application download and deploy Jenkins on any web/application server, and it can run on any platform independent of operating system. Integrate Jenkins with majority build tools like Ant, Maven, and Gradle. Jenkins provides plugin to interact with version control systems like Git, SVN, and Mercurial etc…
Importance of Jenkins:
Jenkins tool is used for continuous integration, Jenkins will prepares build whenever a developer commits to code to shared repository, and the latest build can handover to testing team for Quality Analysis. This will remove the problem of finding later occurrence of issues in build life-cycle. The common practice is that whenever a developer commits the code, Jenkins will start the build process.
The workflow will like below:
Either download war file from Jenkins site (https://updates.jenkins-ci.org/latest/jenkins.war) or Install exe file for windows from location (http://ftp-chi.osuosl.org/pub/jenkins/windows/jenkins-2.59.zip), Extract and install executable file.
It will create a windows service for serving Jenkins application.
If we download war file, start the Jenkins using java –jar jenkins.war command. After the command is run, different program will run, one of which is the withdrawal of the war file which is complete by an embedded webserver called winstone.
After successful message browse the link http://localhost:8080 to access Jenkins.
The default password will be stored in initialAdminPassword which is in secrets folder of Jenkins installation directory. Modify the password after login.
Installing Plugins for Jenkins:
Navigate to http://localhost:8080/pluginManager/available to see all default available plugins for Jenkins.
Select the plugins to install.
After the successful installation we see the below screen:
We need to setup the JDK and Maven in Jenkins: Navigate to Configure Tool Page:
Similarly Install “GIT server Plugin” plugin and using configuration tool page configure the Git.
Automated Deployment to Application Servers: they are many plugins available to move the build to application server deployment location, for example we can use Deploy to container Plugin to do automatic deployments.
The plugin takes war/jar/ear file from build and deploys to running instance of the application server.
Jenkins –Setup Build Jobs:
From Jenkins Home page, create jobs, after clicking create new job it will navigate to below page.
Where we can specify Job name and select type of the project for example Maven Project.
After clicking on ok button, we see the below screen. Where we can configure the Git Repository details.
And Build steps, choose Invoke top-level Maven targets and specify the maven goal for project.
After entering all the details save job.
Click Build Now in left side Menu to trigger the build.
Build History Job instance is created and monitor the progress of the job.
Once the build is completed, a status of the build will show if the build was successful or not. This case, the instruction developed has been executed successfully. Click on the #1 in the Build history to bring up the details of the build.
By clicking on Console Output link to see the details of the build.
Distributed Builds: Some times more than one build machines are required for heavier and larger project build on regular projects, running on all jobs on same node is not best option. We can configure the Slave machines which will take load from master node so that load on master node will be reduced.
Sometimes we need several different environments to test builds, in this we can create a slave for each environment. Some jobs may need to run the multiple nested jobs to complete job, if nested jobs are independent like running on job on windows, Ubuntu etc… then we can run each nested job on different slave parallel so that build time can be minimized.
A slave computer is set up to take offload build projects from master node, once setup is completed distribution is automatic. Add label to each slave server, based on setup stick to one slave server and pick a slave server from label.
Since each serf runs a particular program called a “slave agent” there is no need to install the full Jenkins (package or compiled binaries) on a slave. There are various ways to start slave agents, but in the end the slave agent and Jenkins master needs to establish a bi-directional communication link (for example a TCP/IP socket.) in order to operate.
1) We need to navigate to Manage Jenkins Section.
2) Click on New Node.
3) Enter Name and select the checkbox.
4) By default the newly created machine will be in Offline initially, once it validate the fields which we enter previously, if validation is success it will come to online state, but user can move slave machine to offline.
Jenkins also provide Code coverage plugin which will collect information Source Code Analysis reports like CheckStyle, Find Bugs, and PMD etc…
Source Code Analysis Collector is Jenkins plugin which will combines the individual results of these plugins into a single trend graph and view.
The plugins can provide information such as
- The total number of warnings in a job
- A showing of the new and fixed warnings of a build
- Trend Reports showing the number of warnings per build
- Overview of the found warnings per module, package, category, or type
- Detailed reports of the found warnings optionally filtered by severity (or new and fixed)
Conclusion: Jenkins is Continuous Integration tool, using which we can automate build process, deployments, code analysis, etc.., Jenkins have large number of variety plugins for each of the operation, and we also monitor the status of Jobs. If project contains many modules we also creates nodes for Jenkins for load distributions, it is one of the J2EE application and Java Software Development Company, we can deploy on any application server on any environment.