Jenkins is a free and open source automation server . It helps automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery.
Jenkins can be installed through native system packages, Docker, or even run standalone by any machine with a Java Runtime Environment (JRE) installed.
It is used to continuously build and test software projects, enabling developers to set up a CI/CD environment. It also supports version control tools like Subversion, Git, Mercurial, and Maven.
Let’s take a look at some of the main scenarios Jenkins plays a critical part in :
1) Continuous Integration (CI)
Continuous integration is a practice that forces developers to frequently integrate their code into a central repository. Instead of building out new features to the end without any quality measurement, every change is tested against the central repository in order to anticipate errors.
Every developer commits daily to a shared mainline and every commit triggers an automated process to build and test. If building or testing fails it can be detected and fixed within minutes without compromising the whole structure, workflow, and project. In that way, it is possible to isolate problems, solving them faster and provide higher-quality products.
2) Continuous Delivery (CD)
The main goal in continuous delivery is to make deployments predictable as routine activities that can be achieved upon request. To be successful, the code needs to always be in a deployable state even when there is a scenario with lots of developers working and making changes on a daily basis. All of the code progress and changes are delivered in a nonstop way with high quality and low risks. The end result is one or more artifacts that can be deployed to production.
3) Continuous Deployment (CD)
Continuous deployment, also known as continuous implementation, is an advanced stage of continuous delivery that the automation process does not end at the delivery stage. In this methodology, every change that is validated at the automatic testing stage is later implemented at the production stage.
The fail fast strategy is always of the utmost importance when deploying to production. Since every change is deployed to production, it is possible to identify edge cases and unexpected behaviors that would be very hard to identify with automated tests. To fully take advantage of continuous deployment, it is important to have solid logging technology that allows you to identify the increasing error count on newer versions. In addition, a trustworthy orchestration technology like Kubernetes that will allow the new version to slowly be deployed to users until the full rollout or an incident is detected and the version is canceled.
As a job executor, Jenkins can be used to automate repetitive tasks like backup/restore databases, turn on or turn off machines, collect statistics about a service and other tasks. Since every job can be scheduled, repetitive tasks can have a desired time interval (like once a day, once a week, every fifth day of the month, and so forth).
Lets see some of the use-cases of Jenkins :
✨ Jenkins with GitHub✨
With the help of the Git plugin Jenkins can easily pull source code from any Git repository that the Jenkins build node can access.
The GitHub plugin extends upon that integration further by providing improved bi-directional integration with GitHub. Allowing you to set up a Service Hook which will hit your Jenkins instance every time a change is pushed to GitHub.
Authenticating with GitHub
Using the GitHub Authentication plugin it is possible to use GitHub’s own authentication scheme for implementing authentication in your Jenkins instance.
✨ Jenkins and Android ✨
Building, Testing & Deploying Android Apps with Jenkins
As one of the predominant mobile platforms, Android is attractive to a number of developers, but it does bring it’s own set of challenges with it. With an extremely broad set of devices available on the market, building and testing for the matrix of device configurations can be very challenging. With the Android emulator plugin however, it is possible to build and test on a myriad of emulated devices.
When combined with the Google Play Publisher plugin, Android developers can build true continuous delivery pipeline, sending builds to an alpha channel in Google Play for release or further testing.
✨ Jenkins and Docker ✨
Combining Jenkins and Docker together can bring improved speed and consistency to your automation tasks.
What this offers to Jenkins users is a means to isolate different jobs from one another, quickly clean a job’s workspace or even dynamically deploy or schedule jobs with Docker containers to increase resource utilization and efficiency
✨ Jenkins in the Embedded World ✨
Jenkins is an extensible framework, which can be applied to many areas including embedded software and even hardware development. With proper configuration, Jenkins can be operated with hardware peripherals attached to build agents to accelerate development of all kinds of embedded use-cases.
Jenkins has plugins for integration with common tools such as GCC, Microsoft Visual Studio, etc. Currently there are not domain-specific embedded development or electronic design automation tool integrations. Jenkins can however integrate with practically any tool which can provide a command-line interface via its shell/batch scripting integration.
✨ Pipeline as Code with Jenkins ✨
The default interaction model with Jenkins, historically, has been very web UI driven, requiring users to manually create jobs, then manually fill in the details through a web browser. This requires additional effort to create and manage jobs to test and build multiple projects, it also keeps the configuration of a job to build/test/deploy separate from the actual code being built/tested/deployed. This prevents users from applying their existing CI/CD best practices to the job configurations themselves.
With the introduction of the Pipeline plugin, users now can implement a project’s entire build/test/deploy pipeline in a Jenkinsfile and store that alongside their code, treating their pipeline as another piece of code checked into source control.
The Pipeline plugin was inspired by the Build Flow plugin but aims to improve upon some concepts explored by Build Flow with features like:
- the ability to suspend/resume of executing jobs.
- checking the pipeline definition into source control (Jenkinsfile)
- support for extending the domain specific language with additional, organization specific steps, via the “Shared Libraries” feature.
▶ ▶ Jenkins lowers the Effort of repeated coding
with the uses of Jenkins, one can convert a command prompt code into a GUI button click. This can be done by wrapping up the script as a Jenkins job. Parameterized Jenkins jobs can be created for customization or to take user input. Thus, hundreds of lines of code writing can be saved.
▶ ▶ Integration of Individual Jobs
Jenkins jobs are usually small tools. They serve small purposes and quite simple. Jenkins provides pipeline plugin using which multiple jobs can be combined. Pipelining provides such benefit which Linux users can understand more than anyone. Both sequential or parallel combination is possible.
▶ ▶ Synchronization with Slack
A large team uses a centralized platform for communication. Slack is one such most popular platform. Slack integration can be done to Jenkins and thus communication such as activities have been triggered, its time, users name, results etc. can be shared with other people.
▶ ▶ Effortless Auditing
Jenkins jobs, when run, capture console output from stdout as well as stderr. Troubleshooting with the uses of Jenkins is also very clear. For performance tuning each individual job, run timing can be measured and slowest step can be identified using Time stamper plugin.
▶ ▶ Greater data support for project management
For project management, each activity is wrapped as a Jenkins job. For each Jenkins job, success or failure can be identified, and job completion time can be measured.
Jenkins supports REST API or SDK to measure success, failure or time.
Some useful Jenkins plugins are given below:
- Pipeline Plugin,
- Slack Plugin,
- Dashboard View,
- JobConfigHistory Plugin,
- Naginator Plugin,
- Git Plugin, and
- GitHub pulls request builder plugin.
▶ ▶ Manual Tests option
Sometimes things work great locally but fail when pushed on a central system. This happens because, by the time they push, things change. Continuous Integration tests the code against the current state of a code base and is done in the production-like environment.
▶ ▶ Increased Code Coverage
CI servers such as Jenkins can check code for test coverage. Tests increases code coverage. This inspires transparency and accountability in team members. Results of tests are displayed on build pipeline which ensures team member follow required guild lines. Code coverage similar to code review ensures that testing is a transparent process among team members.
▶ ▶ Code deployment to Production
Jenkins or another CI system can deploy code to staging or production automatically if all the tests written for the same within a specific feature or release branch are green. This is formally known as Continuous Deployment as well. Changes before a merge activity can be made visible too. This can be done in a dynamic staging environment, and after they are merged it is deployed directly to a central staging system, pre-production system or even a production environment.
▶ ▶ Avoid Broken Code during shipping
Continuous integration ensures that code coverage is good, it is tested well and only merged when all tests are successful. This makes sure that the master builds are not broken, and no broken code is shipped to a production environment. In case, the master build is broken, such systems can trigger a warning to all developers.
▶ ▶ Decrease Code Review Time
CI systems such as Jenkins and Version Control System such as Git can communicate with each other and inform the users when a merge request is suitable for merge. This is usually when all the tests are passed, and all other requirements are met. In addition to that, the difference in code coverage can also be reported in the merge request itself. This dramatically reduces the time taken to review a merge request.
Case Study : Preply’s online education platform with CI/CD
To support this online education platform — and over 100,000 students and 25,000 tutors — Preply’s engineering team set out to create a fully automated CI/CD process for its software and development projects.
Maintain their ‘everything as code’ mantra and enhance their current Jenkins installation. Eliminate manual intervention by using a configuration-as-a-code only solution for all software development.
A flexible and scalable CI/CD pipeline that enables their team to introduce and accelerate the deployment of new builds without jeopardizing the entire service.
- Daily release rate increased from 1 to 40 and continue growing
- Rollback time decreased from 45 minutes to 60–120 seconds
- Deployment time reduced from 90 to 5–40 minutes (depending on service)
- Vastly improved conversion and user experience
Case Study : Graylog’s DevOps Infrastructure To Support A Complex & Dynamic Platform
For this industry leading log management platform powering tens of thousands of enterprise installations worldwide, their new build and release manager set out to leverage the power and flexibility of Jenkins’ latest features to enhance their current DevOps environment.
Upgrade Graylog’s Jenkins installation with the latest version to:
- enable expanded use of infrastructure-as-code
- ensure quick and straightforward disaster recovery for Jenkins
- provide visibility for all during the release process
A flexible and modern DevOps platform for Graylog.
- Maintainability of job improved through infrastructure-as-code
- Upgrade performance moved from never upgraded to upgrades within minutes
- Observability of builds increased through Blue Ocean UI
- A scalable infrastructure to support 40,000 enterprise installations and thousands of IT professionals worldwide