The efficiency of the software development life cycle is what differentiates a successful app delivery from a faulty one. The industry is emphasizing on the need to increase the productivity of the development process with speedy deployment. This can be achieved with continuous integration and continuous delivery. In agile development, there is a constant need to test the code regularly with continuous integrations of the builds. Jenkins helps in optimizing the CI/CD process. So let’s start with Continuous integration and then we will move on to the role of Jenkins in achieve continuous integration.
What is Continuous Integration
Continuous integration is a process in which multiple commits are made every day and each commit code is built and tested immediately. Once the test is passed the build is tested for deployment and then it is sent to production. A CI/CD pipeline consists of Continuous Integration server like Jenkins, Source Control tool, Build tool, and an automation testing framework like Selenium, Appium, etc. There are many benefits of continuous integration and according to the project requirement, the development team can choose the best continuous integration tools.
What is Jenkins
Jenkins is an open-source server-based application written in Java used to achieve continuous integration in an automated fashion. It is popular because it makes monitoring the repeated task which arises during the development phase. While working on the project, Jenkins automation will continuously test the builds and recognize the errors in the early stages of the development. Jenkins speeds up the software development process by automating the build and test quickly.
Why CI needs Jenkins
When a team of developers work on a project and use a shared repository, we have observed that some take 20 days and others take 25 days to complete. When the developers are done with coding, they commit at the same time, and then the build is tested. This way a single build is completed after many days. But with Jenkins, the build, and the testing of code can be completed many times in the same day. Once the testing is phase is completed, then the source code will be deployed into the test server. Jenkins will notify the developers if the build fails.
Since the code was built all at once, some developers would have to wait for others to complete which is not efficient. Previously, it was difficult to detect and fix bugs for multiple commits. Now with Jenkins, once the developer commits, the code is built immediately, and thus it is easy to find the code that causes build failure.
Earlier the code build and test process were done manually and this was the reason for many errors. This was rectified by the automated build and testing in Jenkins.
One more issue was that code was deployed when all the bugs were fixed and this made the development cycle slow. Jenkins helps speed up the process as the code is deployed after every build and test.
Advantages and Disadvantages
The best thing about Jenkins is that it is an open-source tool and the community takes feedback from the users for enhancement of the project. Every three months, there is a stable release and there are more than 320 plugins that are published in its plugins database. It also supports cloud-based architecture and it can be integrated with cloud-based platforms.
Some flaws include its outdated user interface and lack in the overall user experience in some ways. It runs on a server that requires maintenance and skills to install, configure and monitor the activity. There will be some issues with the setting changes and the continuous integration will break which will need developers’ attention.
Use of Jenkins to Achieve CI/CD Pipeline with pCloudy
Here we can see a sample app code that will be used in this process.
This app is also hosted on Git as shown in the figure.
Go to the configuration page in Jenkins for this project.
We have configured it to pCloudySampleAndroidApp. Jenkins will pick up this project from the location and build it. Then we need to get the Github access and branch to pick the code. The source control mechanism should be polled with a schedule.
In this build, we will build the android studio project using Gradle wrapper.
Here we can see the location of the Gradle wrapper and the task that needs to be performed by Gradle.
Next step is to integrate Jenkins and the plugin can be taken from the pCloudy website.
In Step 1, we have mentioned the URL of the device cloud followed by the user name and the API key. You can retrieve your API access key by going to the settings page in pCloudy.
In step 2 we need to provide the command line path where we have mentioned the Appium Jar file which has the test cases. Next, you need to give the path of the app that has been build by Jenkins and then mention the automation duration.
In step 3, we can choose the device on which we want to run Appium. You can select the Android version and the preferred device with the desired specifications. We have selected two devices for the process.
Now we can go back to the code and check how the entire configuration comes together.
After making the changes in the code, go to the version control system and add a commit.
Once the code is committed we will need to push the code. Once the push is successful you can check in the Git if it is showing the code change.
Now again we need to go to Jenkins and click on “Build Now”.
On the next screen, we can see the initiation of Gradle Daemon.
Now go to active sessions on the pCloudy platform to see the live view of the activity in the devices.
This is how you can make changes in the code and push the code into Git from where Jenkins downloads the code and uploads the build into pCloudy. This process takes a few minutes and we will be able to see the test activity live which is an advantage of integrating the Jenkins-based build system with pCloudy’s automation.
Jenkins is the soul of the continuous integration process as it builds and tests the app continuously. It also makes it easier to integrate changes to the process when needed. As most of the process is automated, this saves time and effort which can be used to perform other tasks related to the delivery. It has some issues like the old UI but the benefits like an active opensource community overshadow the fewer disadvantages. And that is why Jenkins is the most popular CI server among the developers.