What is continuous integration?
Continuous integration (CI) is a process in which whenever a developer check-in code in shared repository, the whole project is automatically build and tested, in order to find integration issues.
Why continuous integration is required if we can do this task manually also?
If we talk about the current software development system, as soon as the developer develops the code he pushes the code in the shared repository and at the same time when he is integrating two module, he wants that whether the built is stable or not. He is performing unit testing, whereas the integration testing is done by another team (testing team) and then the code is finally deployed. If we do this manually we need to wait for the testing team to test the whole build and give a go ahead if the built is successful or else again developer has to fix the issue if the built is not successful and has to wait for the go ahead from the testing team. So in order to automate the whole system, Continuous integration comes into play.
Continuous integration reveals the integration issues at very early stage.
How CI works?
As a developer I check-in the code to my local repository (suppose it may be Git). Once all the check-in has been done, I will push the entire code to the remote repository (suppose it may be Git Hub), where all the developer at the end of the day pushes their code. There is a CI server which is actually tracking the remote repository. Suppose anything new happened in remote repository whether it is addition of any code or modification or any new build has come into the repository than this CI server will actually going to perform the compilation, unit testing, execute the regression testing and publish the reports. Here, build management tool such as Maven/ ANT is also configured with CI tools to perform the task.
Benefits of CI
- Continuously integrates the whole project, thereby eliminating the Integration phase.
- Catches Issues at very early stage.
- Reduces time for de-bugging, as issues are caught at each integration.
- Help to deliver the product more rapidly.
Famous CI tools
- Jenkins
- Hudson
- Team city
- Team foundation server
- GitLab
In above Jenkins and Hudson are free CI tools.
What is Jenkins?
Jenkins is an open-source Continuous integration tool/server, which is used to automate all sort of task related to building, testing, delivering or deploying the whole project whenever needed.
Jenkins is originally created as Hudson, but after dispute with Oracle, this project is separated by open source community as “Jenkins”.
Installing and Running Jenkins
Use following steps to install and run Jenkins on local environment:
- Open CMD and run following command to start the server : java –jar jenkins.war –httpPort=8080.
Note: - If 8080 port is in use give the port number such as 9090 or 8090.
Configuring Jenkins Plugin
More than 600 plug-ins are available to customize Jenkins as per project requirements.
To Manage Jenkins plug-ins use following steps:
- Open Jenkins in browser
- Click on “Manage Jenkins”
- Click on “Manage Plug-ins”.
- Go to “Available Plug-ins” and choose the plug-in you need.
Note: - The important plugin that should be installed are CVS plugin, Git plugin and GitClient plugin.
Jenkins configuration wizard
In order to connect Jenkins with other tools (i.e java, maven etc.) first we need to configure the Jenkins. Use following steps to configure Jenkins:
- Open Jenkins in any browser.
- Click on “Manage Jenkins”
- Click on “Global tool configuration”
- Now configure following :
- Java :
a) Set the path of “Java_Home” variable as of System variable. (e.g. C:\Program Files\Java\jdk1.8.0_51)
- Git :
a) Set the path of Git installation directory (e.g. C:\Program Files\Git\bin\git.exe)
- Maven:
a) Set the path of Maven installation directory as of Maven_Home variable ( e.g. E:\maven2\apache-maven-3.0.5-bin\apache-maven-3.0.5)
5. Now “save” the above settings.