What is continuous integration? In simple words, CI is a software engineering practice where each check-in made by a developer is verified by either of the following:
- Pull mechanism: Executing an automated build at a scheduled time
- Push mechanism: Executing an automated build when changes are saved in the repository
This step is followed by executing a unit test against the latest changes available in the source code repository.
The main benefit of continuous integration is quick feedback based on the result of build execution. If it is successful, all is well; else, assign responsibility to the developer whose commit has broken the build, notify all stakeholders, and fix the issue.
So why is CI needed? Because it makes things simple and helps us identify bugs or errors in the code at a very early stage of development, when it is relatively easy to fix them. Just imagine if the same scenario takes place after a long duration and there are too many dependencies and complexities we need to manage. In the early stages, it is far easier to cure and fix issues; consider health issues as an analogy, and things will be clearer in this context.
Continuous integration is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.
CI is a significant part and in fact a base for the release-management strategy of any organization that wants to develop a DevOps culture.
Jenkins provides us with multiple ways to install it for all types of users. We can install it on at least the following operating systems:
- Mac OS X
- CentOS/Fedora/Red Hat
One of the easiest options I recommend is to use a WAR file. A WAR file can be used with or without a container or web application server. Having Java is a must before we try to use a WAR file for Jenkins, which can be done as follows:
- Download thewar file from https://jenkins.io/.
- Open command prompt in Windows or a terminal in Linux, go to the directory where the war file is stored, and execute the following command:
java – jar jenkins.war
- Once Jenkins is fully up and running, as shown in the following screenshot, explore it in the web browser by visiting http://localhost:8080.
- By default, Jenkins works on port 8080. Execute the following command from the command line:
java -jar jenkins.war –httpPort=9999
- For HTTPS, use the following command:
java -jar jenkins.war –httpsPort=8888
- Once Jenkins is running, visit the Jenkins home directory. In our case, we have installed Jenkins 2 on a CentOS 6.7 virtual machine.
- Go to /home/<username>/.jenkins, as shown in the following screenshot. If you can’t see the .jenkins directory, make sure hidden files are visible. In CentOS, press Ctrl+H to make hidden files visible.
For more details get the DevOps for Web Development book.
It is also available at: