Watchful Mr. Jenkins – a little about Continuous Integration.

DevOps Engineer

The one who does not make a mistake usually does nothing. Mistakes happen. However, it is important to quickly and effectively eliminate and draw conclusions. An effective form of error verification is well-known by software developers Continuous Integration. One of CI’s most popular tools is Jenkins, which allows you to automate the development process, such as running a test, building a project, or collecting information about your operations by setting up tasks (called “jobs”).

What is Continuous Integration (CI)?

It is a process that begins by posting changes to code fragments in a repository. Then such code is built, and further automatic compilations and tests are run. In case of an error, the developer quickly gets feedback. When integration frequently occurs, preferably several times a day, it reduces the number of errors and the cost associated with finding them. It also improves the quality of the software and reduces the time needed to verify and release new software updates.

For the CI process, Jenkins is used, which, for example, automatically downloads code from the repository (through a webhook set, for instance, in Bitbucket, which informs it of this) and proceeds to a preset set of actions. It could be, for example, compiling, firing unit tests, and uploading changes to the test environment. We can set up tasks in various ways that suit us. 

For applications based on modern PHP frameworks and front-end frameworks like React, the first task will be to start Composer to update packages, run webpack to compile JS and CSS files, then run Jenkins to perform the unit tests necessary to test every single part of the application and detect errors in the early phase. In addition, Jenkins can run static code analysis and launch automated tests (such as Selenium) to minimize the need for manual tests or regression testing and simply automatize the entire web application testing process. If you use Docker, it can also build whole docker container images and upload them to Docker Registry (you can use Amazon ECR for that).

Inform and release changes as soon as possible!

The most significant, fundamental feature of continuous integration is communicating information as quickly as possible. We can rely on that with Jenkins. Each deviation detected in the test is appropriately communicated by sending a message to the team’s integrated mailbox or via communicator (e.g. Slack). Jenkins can also get in touch with developers on Twitter, Skype, or talk to an app on smartphones 🙂

Jenkins - sample view
The main view of ‘job list’ in Jenkins – you can see the status of the last build and some additional information.

The notification mechanism is extremely easy to work with because it knows, almost immediately, which code is OK and which does not work properly and needs to be corrected. CI carefully checks for all errors in the code provided by the developer in every new version thrown into the repository. Jenkins will also tell you where the error in the file is located and who is responsible for it [our blog post about the system of “penalties” and “prizes” for team members will be available shortly].

Jenkins will also notify us when the problem is resolved. Appropriate information will reach every programmer interested in the project, and as a result, the entire team is aware of the current status of work, and it is easier to plan the tasks. After a successful build process, we can finally release our changes into the selected environment – during daily work, the changes land in the “dev” environment, where programmers and testers can test the given functionality. Jenkins is also responsible for releasing these changes into the “stage” environment as well as production. You will save a lot of time this way, and releases will become easier, and more stable so that they will be done more often.

Building CD with Jenkins

Continuous Delivery allows developers to automate testing beyond unit tests, verifying application updates across multiple dimensions before deploying them to customers. 

One of the key elements of Continuous Delivery is the deployment pipeline (pipelines). It models the software release process, defining the servers and environments on which compilations will be deployed and the manual and automated approvals required at each stage of the process.

Different applications may use other pipelines, or the same application may use different pipelines for different releases. It all depends on the context and needs of the software.

How does Jenkins help with Continuous Delivery?

Jenkins was initially designed as a compilation automation server (open source automation server). Because a compilation script can be just any script, Jenkins can be used for many operations… from running a CD pipeline to even PowerShell scripts. 

Although Jenkins is not directly responsible for Continuous Delivery, with the help of the pre-installed Pipelines plugin (originally called workflows), Jenkins and dedicated CD tools can help with this. When you use any deployment tool with Jenkins, you get all the value that Jenkins currently offers, like compilation/CI automation, testing and/or running any scripts, and a flexible release process (continuous deployment). It also has the added benefit of being more accessible to team members who are not Jenkins experts.

Static code analysis

One of the next sample things that Jenkins can do is perform static code analysis – it analyzes syntax correctness, finds dangerous and outdated features, memory leaks, buffer overflows, SQL Injections, and can detect unnecessary code repetitions or unused elements. This allows you to increase productivity, detect bottlenecks or inefficient construction. In addition, we can automatically verify that the developer has actually made the appropriate description in the code for the classes and methods (so-called doc) – if the programmers had forgotten it, it would not be possible to generate documentation for the project. However, it must be remembered that Jenkins is not for writing the documentation itself, but only for the generation and automation of the process.

What can I use Jenkins for?

C#, NodeJS, PHP, Java? It doesn’t matter – Jenkins is for everyone. The application is cross-platform, so it can be installed on Windows, Ubuntu, MacOS. In addition, although Jenkins is written in Java, it is suitable for all projects, even those created in C #/NET. Jenkins supports the automation of some of the code development, test, and documentation procedures. This is a powerful compendium of information about your project. And last, but not least, it really helps in releasing changes to different environments (dev, stage, production). Once used, you’ll see a lot of benefits and save a lot of time. Is it worth? We think you know the answer.

Related Posts
22 August 2022
React.js From a Developer’s Point of View – Pros & Cons
React.js seems to be everywhere. Companies, big and small, are using it to develop their…
Read more
12 December 2022
Context API vs Redux – which should you choose?
Which is better, Context API or Redux in React projects? The answer to this question…
Read more
14 July 2023
Boosting Cloud Security with AWS Services
If you’re running a business in 2023, chances are you’re using the cloud for some…
Read more