Jenkins & its use cases

Gulsha Chawla
10 min readAug 24, 2021

๐““๐“ฎ๐“ฟ๐“ฎ๐“ต๐“ธ๐“น๐“ถ๐“ฎ๐“ท๐“ฝ ๐“‘๐“ฎ๐“ฏ๐“ธ๐“ป๐“ฎ ๐“™๐“ฎ๐“ท๐“ด๐“ฒ๐“ท๐“ผ

Before the advent of Jenkins, developers had to complete code testing before they could check for errors.

โœ’๏ธDevelopers on teams, tending to work independently, each created large segments of code to add to the base code. The entire source code would be checked for errors a time-consuming and challenging undertaking.

โœ’๏ธMultiple developers would each send commits to version control, increasing the time required to identify and fix bugs. There was no iterative code improvement, and the software delivery process was slow.

Now letโ€™s understand what actually is Jenkins & how it is usedโ€ฆ

๐“ฆ๐“ฑ๐“ช๐“ฝ ๐“ฒ๐“ผ ๐“™๐“ฎ๐“ท๐“ด๐“ฒ๐“ท๐“ผ?

โœ’๏ธJenkins is a self-contained, open-source automation server that can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software.

โœ’๏ธJenkins can be installed through native system packages, Docker, or even run standalone by any machine with a Java Runtime Environment (JRE) installed.

โœ’๏ธIt works with multiple programming languages and can run on various platforms (Windows, Linux, and macOS). It is widely used as a CI (Continuous Integration) & CD (Continuous Delivery) tool.

โœ’๏ธIt has vast community support, and there are many plugins available for integrating it with other tools like Slack, GitHub, Docker. Also, anyone can develop a Jenkins plugin and contribute to it.

โœ’๏ธBy using Jenkins, software companies can accelerate their software development process, as Jenkins can automate a build and run tests to ensure the functionality is working fine.

โœ’๏ธJenkins supports the entire software development life cycle that includes building, testing, documenting the software, and deploying.

๐“’๐“ธ๐“ท๐“ฝ๐“ฒ๐“ท๐“พ๐“ธ๐“พ๐“ผ ๐“˜๐“ท๐“ฝ๐“ฎ๐“ฐ๐“ป๐“ช๐“ฝ๐“ฒ๐“ธ๐“ท ๐”€๐“ฒ๐“ฝ๐“ฑ ๐“™๐“ฎ๐“ท๐“ด๐“ฒ๐“ท๐“ผ

โœ’๏ธContinuous Integration is a software development process where a code is continuously tested after a commit, to ensure there are no bugs.

โœ’๏ธIn large teams, many developers work on the same code base. Thus, any of the multiple commits can have a bug. With continuous integration, bugs can be identified early and fixed before pushing changes to production. Any new code is integrated into one executable form, termed a build. If the build is green (i.e. all ok), then the executable artifact can be deployed. If not, the bug needs to be fixed, and the new build is tested again.

Letโ€™s see how to get started with Jenkins CI.

๐“—๐“ธ๐”€ ๐“ฝ๐“ธ ๐“ฌ๐“ป๐“ฎ๐“ช๐“ฝ๐“ฎ ๐“ช ๐“’๐“˜ ๐“น๐“ฒ๐“น๐“ฎ๐“ต๐“ฒ๐“ท๐“ฎ ๐“ฒ๐“ท ๐“™๐“ฎ๐“ท๐“ด๐“ฒ๐“ท๐“ผ?

1. Declarative Pipeline

Jenkins pipeline can be written in a declarative manner with the โ€œJenkins syntaxโ€œ. Jenkins syntax is a Groovy DSL (Domain Specific Language) that is used to write stages of the pipeline. The DSL internally gets converted into XML to make the Jenkins pipeline. A โ€œstageโ€ in a pipeline is a group of steps to be executed in the pipeline.

2. Jenkins Job Builder

โœ’๏ธJJB (Jenkins job builder) is a tool to create a pipeline using YAML configuration. The Jenkins pipeline can be written in YAML and with the help of the JJB tool, it converts the YAML configuration in XML format and pushes it into Jenkins to create pipelines. It is comparatively easy to write YAML configuration than writing full-fleshed code in Jenkins syntax.

โœ’๏ธThis tool also enables the use of โ€œPipeline as Codeโ€ so that a pipeline code can be pushed into a git repo and the pipeline gets created or updated in Jenkins. The tool also helps with the templatization of the pipeline code.

๐“‘๐“ฎ๐“ท๐“ฎ๐“ฏ๐“ฒ๐“ฝ๐“ผ ๐“ธ๐“ฏ ๐“พ๐“ผ๐“ฒ๐“ท๐“ฐ ๐“™๐“ฎ๐“ท๐“ด๐“ฒ๐“ท๐“ผ ๐“’๐“˜

  1. Reduced development cycle: Since every commit is getting built and tested, it allows releasing new features to the user faster and with fewer errors
  2. Shorter time to integrate code: Before the use of Jenkins CI, integration of code was done manually, thus taking a few days. In some cases, it might happen that the code is not in a running state, and it is hard to debug as it might have gone through various commits in the repository. Integrating code after every commit ensures that at least the functionality is not broken after a commit
  3. Faster feedback to developer teams: Whenever a test breaks during a commit, developers get feedback and hence improve the code there and then. Otherwise, debugging the issue can be very difficult given teams would not be sure which commit resulted in the bug
  4. Automated workflow: Teams do not have to worry about running a manual test for each commit. The Jenkins CI pipeline checks the latest code and builds the code along with the tests. If the test is green, it can deploy the project in a specific environment else it can notify the developer by breaking the build

๐“’๐“ธ๐“ท๐“ฌ๐“ฎ๐“ป๐“ท๐“ผ ๐“พ๐“ผ๐“ฒ๐“ท๐“ฐ ๐“™๐“ฎ๐“ท๐“ด๐“ฒ๐“ท๐“ผ ๐“’๐“˜

  1. Cost: Running a Jenkins CI server requires some infrastructure setup and its costly to deploy a Jenkins CI over the cloud
  2. Maintenance: Spinning up a Jenkins CI server is time-consuming. Jenkins CI also needs maintenance in case of adding a stage in the pipeline or upgrading the Jenkins CI server to incorporate new features.

๐“ฆ๐“ฑ๐“ช๐“ฝ ๐“ช๐“ป๐“ฎ ๐“ฝ๐“ฑ๐“ฎ ๐“™๐“ฎ๐“ท๐“ด๐“ฒ๐“ท๐“ผ ๐“•๐“ฎ๐“ช๐“ฝ๐“พ๐“ป๐“ฎ๐“ผ?

Jenkins offers many attractive features for developers:

  • Easy Installation

Jenkins is a platform-agnostic, self-contained Java-based program, ready to run with packages for Windows, Mac OS, and Unix-like operating systems.

  • Easy Configuration

Jenkins is easily set up and configured using its web interface, featuring error checks and a built-in help function.

  • Available Plugins

There are hundreds of plugins available in the Update Center, integrating with every tool in the CI and CD toolchain.

  • Extensible

Jenkins can be extended using its plugin architecture, providing nearly endless possibilities for what it can do.

  • Easy Distribution

Jenkins can easily distribute work across multiple machines for faster builds, tests, and deployments across multiple platforms.

  • Free Open Source

Jenkins is an open-source resource backed by heavy community support.

๐“™๐“ฎ๐“ท๐“ด๐“ฒ๐“ท๐“ผ ๐“๐“ป๐“ฌ๐“ฑ๐“ฒ๐“ฝ๐“ฎ๐“ฌ๐“ฝ๐“พ๐“ป๐“ฎ

  • Developers commit changes to the source code, found in the repository.
  • The Jenkins CI server checks the repository at regular intervals and pulls any newly available code.
  • The Build Server builds the code into an executable file. In case the build fails, feedback is sent to the developers.
  • Jenkins deploys the build application to the test server. If the test fails, the developers are alerted.
  • If the code is error-free, the tested application is deployed on the production server.
  • The files can contain different codes and be very large, requiring multiple builds. However, a single Jenkins server cannot handle multiple files and builds simultaneously; for that, a distributed Jenkins architecture is necessary.

๐“™๐“ฎ๐“ท๐“ด๐“ฒ๐“ท๐“ผ ๐“œ๐“ช๐“ผ๐“ฝ๐“ฎ๐“ป-๐“ข๐“ต๐“ช๐“ฟ๐“ฎ ๐“๐“ป๐“ฌ๐“ฑ๐“ฒ๐“ฝ๐“ฎ๐“ฌ๐“ฝ๐“พ๐“ป๐“ฎ

โœ’๏ธAs you can see in the diagram provided above, on the left is the Remote source code repository. The Jenkins server accesses the master environment on the left side and the master environment can push down to multiple other Jenkins Slave environments to distribute the workload.

โœ’๏ธThat lets you run multiple builds, tests, and production environments across the entire architecture. Jenkins Slaves can be running different build versions of the code for different operating systems and the server Master controls how each of the builds operates.

โœ’๏ธSupported on a master-slave architecture, Jenkins comprises many slaves working for a master. This architecture โ€” the Jenkins Distributed Build โ€” can run identical test cases in different environments. Results are collected and combined on the master node for monitoring.

The Bottom Line

โœ’๏ธJenkins provides developers with an excellent framework from which they can develop and test new codes, resulting in the faster delivery of better quality software. By avoiding costly delays and log jams, developers can become an organizationโ€™s MVPs.

๐“™๐“ฎ๐“ท๐“ด๐“ฒ๐“ท๐“ผ ๐“’๐“ช๐“ผ๐“ฎ ๐“ข๐“ฝ๐“พ๐“ญ๐”‚: ๐™ถ๐šŠ๐š’๐š—๐šœ๐š’๐š๐š‘๐š

๐Ÿ“–When developing a thriving ecosystem of the best and smartest customer success technologies, a solid DevSecOps foundation is essential. Gainsight, a leading customer success platform provider, chose to humanize the customer experience with innovative technology.

๐Ÿ“–How? The answer is two-fold. First, they built a CX platform that simplifies and facilitates day-to-day operations. Second, they turn disparate customer data from multiple sources into insights and actions that drive measurable business outcomes. By presenting related data, tasks, and workflows across the customer success tech stack, Gainsight can help drive more relevant customer engagement, faster, for the hundreds of clients they serve.

๐Ÿ“–With a mantra to โ€œnever stop looking for the next best thing,โ€ Gainsight is continuously creating cutting-edge products and services for their clients and their community. By empowering customer-focused businesses to deliver exceptional experiences every day, the Gainsight engineering team needs to be equally agile and deliver products and enhancements as fast as they can innovate. This drove the companyโ€™s tech team to build a more fluid, dynamic DevOps process โ€” using infrastructure as code โ€” with Jenkins at the helm.

CHALLENGE:

Maintain an infrastructure-as-code approach while integrating various tools and programming languages within the platform, all while securing processes with better visibility and air-tight quality control.

SOLUTION:

A flexible and scalable DevSecOps infrastructure that provides Gainsight with keener operational insight, ease of collaboration, and the ability to accelerate releases to stay a step ahead of the competition.

Results :

  • Infrastructure costs were reduced by 40%
  • Builds are 30% faster
  • Better and seamless communication on builds and releases
  • 95% of infrastructure scalable with code
  • Virtually no more manual processes

๐“™๐“ฎ๐“ท๐“ด๐“ฒ๐“ท๐“ผ ๐“พ๐“ผ๐“ฎ-๐“ฌ๐“ช๐“ผ๐“ฎ๐“ผ :

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 to anticipate errors.

Continuous Delivery (CD)

โœ’๏ธContinuous delivery is the ability to make changes of all types such as new features, configuration changes, error fixes, experiments into production safely and efficiently using short work cycles.

โœ’๏ธThe main goal is continuous delivery is to make deployments predictable as routine activities that can be achieved upon request.

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.

Automation

โœ’๏ธ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 service and other tasks. Since every job can be scheduled, repetitive tasks can have the desired time interval (like once a day, once a week, every fifth day of the month, and so forth).

๐“™๐“ฎ๐“ท๐“ด๐“ฒ๐“ท๐“ผ ๐“๐“ต๐“ฝ๐“ฎ๐“ป๐“ท๐“ช๐“ฝ๐“ฒ๐“ฟ๐“ฎ๐“ผ

Although Jenkins is a good option for an automated, CI/CD server, there are other options on the market such as Gitlab CI/CD, Circle CI, Travis, or Bamboo.

GitLab CI/CD

โœ’๏ธGitLab is a full-featured software development platform that includes a module called GitLab CI/CD to leverage the ability to build, test, and deploy without external requirements (such as Jenkins). It is a single application that can be used in all stages of the developersโ€™ work cycle on the same project: product, development, QA, security, and operations.

โœ’๏ธGitLab is a solution that enables teams to cooperate and work from a single step instead of managing thousands of threads across disparate tools. It provides a single data store, one user interface, and one permission model across the developersโ€™ life cycle.

โœ’๏ธGitlab comes in a variety of flavors: there is a community, open-source edition that can be deployed locally, and some paid versions with an increasing number of features.

Circle CI

โœ’๏ธCircle CI is a hosted continuous integration server. After Circle CI is authorized on GitHub or Bitbucket, every code change triggers tests in a clean container or VM.

โœ’๏ธAfter this, an email is sent every time there is a successful test completed or a failure. Any project with a reporting library provides code test coverage results. Circle CI is simple to configure, has a comprehensive web interface, and can be integrated with multiple source code versioning tools.

Bamboo CI

โœ’๏ธBamboo is a solution for continuous integration, deployment, and delivery. Bamboo allows you to create a multi-stage build plan, set up triggers upon commits, and assign agents to builds and deployments.

โœ’๏ธIt also allows you to run automated tests in every code change which makes catching bugs easier and faster. Bamboo supports continuous deliveries as well.

Travis CI

โœ’๏ธTravis is another open-source solution that also offers a free hosted option for open source projects (paid for enterprise clients).

โœ’๏ธIt uses a solution similar to Jenkins Pipelines: you add a file called .travis.yml that describes the projectโ€™s own build workflow. It also has parallel job builds but it does not have the same size of add-ons available for Jenkins.

Conclusion :

โœจIntegration solutions are a key step towards reaching delivery reliability.

โœจEvery developer commits daily to a shared mainline and every commit triggers an automated workflow for building and testing; if building and testing fail it is possible to repair what is wrong quickly and safely and thereby increase productivity in the workflow.

Tิ‹ฮฑษณฦ™ แƒงฯƒฯ… ฯฯƒษพ ษพาฝฮฑิƒฮนษณษ  ษฑแƒง ฮฑษพฦšฮนฦˆส…าฝ๐ŸŽ€

Kาฝาฝฯ Lาฝฮฑษพษณฮนษณษ ๐ŸคฉKาฝาฝฯ Sิ‹ฮฑษพฮนษณษ ๐Ÿคž

Gฯƒฯƒิƒ Dฮฑแƒง!

--

--