Jenkins (http://jenkins-ci.org/) is a Continuous Integration system, facilitates continuous build and test setup for projects. It is an open source tool is similar to 'CruiseControl'. Jenkins is quite stable tool and is used by many Organizations. In this article, we shall discuss about Jenkins, its usage, and configuration.
When we call it 'Continuous Integration System', what is this?
When we work in a team environment using some Source Control / versioning tool, we checkout the work code from repository and starts working on it. After this, every developer used to commit her code to repository whenever she is finished with her work. When application is highly integrated, every commit may change the application integration scenarios, break the integration and probably can induce bugs also, or can break the code compilation etc. Now we need some tool to ensure that we check this inter-dependencies of integration and the stability of latest committed code, as soon as any body commits the code. So we need some tool, which can perform following kind of tasks:
Jenkins support all of above features and even more with different extensions.
Earlier 'Jenkins' was known as 'Hudson'. It was started by its founder (as Hudson) developer while working with Sun Microsystem. Later, it was separated out under a separate name as 'Jenkins' due to some IP (or similar) rights conflicts. Hudson is moved to Eclipse Foundation now. You can find it at http://hudson-ci.org/
After knowing this, one question come to mind is, which tool we should use? Well, this is something everyone need to find herself. However, we have decided to go for 'Jenkins' because it is where most of the original developers and community is working. It is having quite active development releases and is going well as of now. You can find more discussions at http://stackoverflow.com/questions/4973981/how-to-choose-between-hudson-and-jenkins
Jenkins is quite good, as:
How to install Jenkins:
You can find various case studies for Jenkins installation at the bottom of following page: https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins
Jenkins Configuration:
Jenkins can be configured completely using User Interface. But it is good to understand how it works.
Jenkins keeps all of the configuration and runtime data in a directory configured as 'JENKINS_HOME'. Jenkins home cane be configured as
Here is the Jenkins Home Structure from Jenkins documents:
-----------------------------------------------------------
JENKINS_HOME
+- config.xml (jenkins root configuration)
+- *.xml (other site-wide configuration files)
+- userContent (files in this directory will be served under your http://server/userContent/)
+- fingerprints (stores fingerprint records)
+- plugins (stores plugins)
+- jobs
+- [JOBNAME] (sub directory for each job)
+- config.xml (job configuration file)
+- workspace (working directory for the version control system)
+- latest (symbolic link to the last successful build)
+- builds
+- [BUILD_ID] (for each build)
+- build.xml (build result summary)
+- log (log file)
+- changelog.xml (change log)
Back and Restore is quite simple in Jenkins. You simply need to backup the Jenkins_Home. Whenever you want to restore any backup, simply replace the backup 'home' data to the current home path.
Find more administrative options at https://wiki.jenkins-ci.org/display/JENKINS/Administering+Jenkins
How to use Jenkins
Using Jenkins means to configure the jobs for various projects, so that Jenkins can build these projects on various triggers. Here we are describing how to create/configure a job.
There are many advance tasks also which can be achieved with Jenkins, like 'File Fingerprinting' to track the dependencies, and distributed builds etc. Please refer to Jenkins documentation for more details at https://wiki.jenkins-ci.org/display/JENKINS/Meet+Jenkins.
When we call it 'Continuous Integration System', what is this?
When we work in a team environment using some Source Control / versioning tool, we checkout the work code from repository and starts working on it. After this, every developer used to commit her code to repository whenever she is finished with her work. When application is highly integrated, every commit may change the application integration scenarios, break the integration and probably can induce bugs also, or can break the code compilation etc. Now we need some tool to ensure that we check this inter-dependencies of integration and the stability of latest committed code, as soon as any body commits the code. So we need some tool, which can perform following kind of tasks:
- As soon as, any code is committed to source code repository (or at any given schedule), tool takes the update from repository for the project and run its build
- Frequency to check any new commit in source code repository should be configurable
- Build system is designed by team and can be based on any building mechanism like ant or maven. Tool should recognize and support the famous build tools like ant or maven etc
- Tool builds the project and hence all tasks configured with build system will be performed
- If build fails, tool should capture the 'build logs'/'console output' and should be able to send email with all logs to more than one configured email id
- It should have some User Interface where user can be able to see the status of various projects, their last build time, failure, logs etc
- If build passes, it means everything is good with new commit
- Then tool should be able to check if any other project or module is dependent on current project. If yes, it should trigger the build for that project also
- Again controls goes to step 5 for new dependent project
- .....
- http://en.wikipedia.org/wiki/Continuous_integration
- http://martinfowler.com/articles/continuousIntegration.html
Jenkins support all of above features and even more with different extensions.
Earlier 'Jenkins' was known as 'Hudson'. It was started by its founder (as Hudson) developer while working with Sun Microsystem. Later, it was separated out under a separate name as 'Jenkins' due to some IP (or similar) rights conflicts. Hudson is moved to Eclipse Foundation now. You can find it at http://hudson-ci.org/
After knowing this, one question come to mind is, which tool we should use? Well, this is something everyone need to find herself. However, we have decided to go for 'Jenkins' because it is where most of the original developers and community is working. It is having quite active development releases and is going well as of now. You can find more discussions at http://stackoverflow.com/questions/4973981/how-to-choose-between-hudson-and-jenkins
Jenkins is quite good, as:
- Its UI is quite good, simple and easy to understand
- Configuration is very easy. You need not to go to XML files for configuration, rather most of the things are available on UI
- Jenkins provides a dashboard to track all the configured jobs and it refreshes automatically after every few seconds to show the updated status of jobs
- Jenkins supports all the desired features of CI tool as specified above
- Jenkins can be extended by witting the plugins/extensions
- Jenkins provides permanent links for many of its pages, like for "latest build" or for "latest stable build". So these static links can be shared easily with stakeholders.
- It can distribute the build load to multiple machines and hence can utilize power of more than one machine in case if application is quite heavy
- It can keep track that which jar is produced by which build, and which jars were used in a particular build. So it can help in dependency management also.
How to install Jenkins:
- Ensure that you have JDK 1.5 or later installed on the system
- Jenkins can be installed either using its war file distribution or by installing it using installation packages for different platforms
- For war
- Download the war file of Jenkins from http://mirrors.jenkins-ci.org/war/latest/jenkins.war
- Install any servlet container like Tomcat (or JBoss etc)
- Deploy the war file to container
- War will be exploded automatically and Jenkins will be available at http://localhost:8181/jenkins/ (change host and port as per your configuration)
- If you want to run the Jenkins automatically as soon as system starts, you need to configure Tomcat as service (like in windows)
- Then as soon as Tomcat will start, Jenkins will start automatically
- For Installation packages
- Download the Installation package for your operating system from http://jenkins-ci.org/
- Unpack it and run it
- It will install the Jenkins and will also configure it as service (like on windows)
You can find various case studies for Jenkins installation at the bottom of following page: https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins
Jenkins Configuration:
Jenkins can be configured completely using User Interface. But it is good to understand how it works.
Jenkins keeps all of the configuration and runtime data in a directory configured as 'JENKINS_HOME'. Jenkins home cane be configured as
- Set "JENKINS_HOME" environment variable to the new home directory before launching the servlet container.
- Set "JENKINS_HOME" system property to the servlet container.
- Set JNDI environment entry "JENKINS_HOME" to the new directory.
Here is the Jenkins Home Structure from Jenkins documents:
-----------------------------------------------------------
JENKINS_HOME
+- config.xml (jenkins root configuration)
+- *.xml (other site-wide configuration files)
+- userContent (files in this directory will be served under your http://server/userContent/)
+- fingerprints (stores fingerprint records)
+- plugins (stores plugins)
+- jobs
+- [JOBNAME] (sub directory for each job)
+- config.xml (job configuration file)
+- workspace (working directory for the version control system)
+- latest (symbolic link to the last successful build)
+- builds
+- [BUILD_ID] (for each build)
+- build.xml (build result summary)
+- log (log file)
+- changelog.xml (change log)
Back and Restore is quite simple in Jenkins. You simply need to backup the Jenkins_Home. Whenever you want to restore any backup, simply replace the backup 'home' data to the current home path.
Find more administrative options at https://wiki.jenkins-ci.org/display/JENKINS/Administering+Jenkins
How to use Jenkins
Using Jenkins means to configure the jobs for various projects, so that Jenkins can build these projects on various triggers. Here we are describing how to create/configure a job.
- Go to Jenkins home page using the Jenkins URL on your system
- Use Jenkins menu and opt the 'new job' option
- Specify the Job name here
- Choose the Job type from given options as per your project requirement. Like for ant based project, you can opt the first option as 'free style software project'
- You can also create the new job by copying any existing job. For this, select the 'Copy existing job' option and specify the name of existing job
- Submit the request and Jenkins will present you with a page to configure the new job.
- If job is created by copying any existing job, you will find various fields already filled. You need to update these as per new job configuration.
- If job is created fresh, you will get the configuration page with all blank fields
- Various fields and options are:
- Description - fill it for description of current job
- Some other configuration options like whether build need parameters or not. If yes, UI will present you the option to specify the build parameters
- Then you can specify the settings for Source Control / Versioning system
- Select the type of tool you are using like CVS, or SVN
- Specify the Repository URL for current job. For example, if you are building the project > trunk, ensure to give the repository URL till the trunk of the project
- Specify the local system directory, if you want. Otherwise, it will be checkout to the default directory set up by Jenkins.
- Specify checkout strategy. This can be like, update the source code, or check out the fresh copy etc
- You can specify the repository browser if you have configured anyone like 'Fisheye'
- Then you can configure the build triggers. Build Triggers are the events when this job should be activated or run.
- You can configure to build this project after any other project is built. It is useful if current job is dependent on any other project.
- You can configure to build periodically based on any given schedule.
- You can configure to poll the SCM on a given schedule and trigger the build if code is changed.
- After that, next configuration will be for build system. Configure how build system should be invoked based on the build system used in project.
- You can choose from given options like 'Execute Window Batch Command', 'Execute Shell', 'Invoke Ant' or 'Invoke Maven'
- Suppose if you have selected 'Invoke Ant', Jenkins will facilitate you to specify Ant file name, build target and other advance options also like Java Options and Properties etc
- Next step is to configure Post Build Actions, i.e., any event which you want to trigger once the build is done
- There are various options available here. Two good options are to send the email with results to given email ids, and to trigger any other configured job.
- Triggering of any other job is particularly important in dependent projects. You can start building any other dependent project, as soon as, current project is built. This option enables the use case to configure muliple inter-dependent projects.
- Save the configuration and you are done.
- Jenkins will trigger the job at given schedule by you and will email you the results if you have configured it to do that.
There are many advance tasks also which can be achieved with Jenkins, like 'File Fingerprinting' to track the dependencies, and distributed builds etc. Please refer to Jenkins documentation for more details at https://wiki.jenkins-ci.org/display/JENKINS/Meet+Jenkins.
If you like the article, you may contribute by:
- Posting your comments which will add value to the article contents
- Posting the article link on Social Media using the Social Media Bookmark bar
- Connecting with 'VedantaTree' on Facebook (https://www.facebook.com/VedantaTree)
0 comments:
Post a Comment