Back to overview

Jenkins 101: Getting started with Jenkins

| 7 min read

Who or What is Jenkins

Jenkins is a free and open-source CI/CD server. The Java-based application serves as a platform for development, testing, and release.

text

So, Why Jenkins ?

Gitlab CI/CD, GitHub CI/CD, CircleCI, Travis CI, Bitbucket pipeline, etc. are just a few of the CI/CD technologies poopularly used. Depending on the situation, several tools can be used to their full potential. However, Jenkins has a few advantages that makes it preferable in comparison to its rivals.

To begin, as we shall see when we perform the setup, installation and configuration are quick and easy. The platform’s web-based administration is user-friendly, allowing for a wide range of customization in construction processes. For more versatility and personalization, it makes use of a plugin ecosystem. Scalability is provided via Jenkins’ decentralised build agents and executors. Finally, the thriving community of users and thorough online documentation are invaluable resources.

The Jargon of Jenkins

text

1. Jenkins Master Node

The Jenkins administrative dashboard is hosted on the Jenkins controller/master. It provides a web-based administrative portal for setting up build jobs, pipelines, and plugins. The master coordinates the scheduling and distribution of build jobs to the build agents.

2. Jenkins Build Agent

A build agent, also called a slave, is a dedicated server that the Jenkins master communicates with by sending it build task dispatches. As shown in the above graphic, each Agent is capable of running its own OS.

3. Build Project

The Build project defines the parameters for a specific software’s build setup. There are different build requirements for different project types. The default build project on Jenkins are:

Each project choice is described in detail on the Jenkins UI.

4. Label

Grouping together various build agents based on user-defined metadata. Labels can be used to categorise Build Agents in a variety of ways, such as by operating system or by type of build technology.

5. Node

Labels all machines that can run a given build pipeline or project. The location of the execution can now be determined. Scripted pipelines make use of nodes.

6. Agent

Labels all machines that can run a given build pipeline or project. The location of the execution can now be determined. The Declarative pipeline employs agents.

7. Artifact

Created document when a construction has been completed. It could be a.NET assembly, a Java JAR, or even a simple ZIP archive. Artefacts are considered immutable and should not be changed outside of the construction process that originally created them. A fingerprint, which is a checksum of the relevant Artefact file, is used for tracking and tracing purposes.

8. Pipeline

A pipeline is a modelling concept that represents and encapsulates the fundamental building logic and process. Jenkins offers two distinct syntaxes for constructing pipelines:

- Declarative Pipelines

A Syntax with a strong point of view; the rules are more clearly laid out and rigid. They’re less adaptable than scripted pipelines, but they’re simpler to use if you don’t know Groovy.

- Scripted Pipelines

Developed using the Groovy programming language, it allows you to make highly individualised processing pipelines. However, you will need Groovy expertise to get anything done. Those in charge of building and releasing software who aren’t familiar with Groovy may not want to go through the additional learning curve.

Nowadays, declarative pipelines are more used as it is easier to learn and works with most SCM tools such as Gihub, Bitbucket and more.

Automated methods known as a CI/CD (Continuous Integration/Continuous Deployment) pipeline are used to continually integrate code changes, build and test applications, and deploy them to production. Getting updates out to users quickly and reliably is the main focus of a CI/CD workflow.

The various steps that make up a typical CI/CD pipeline are as follows:

9. Stage

Used to divide the entire pipeline into smaller, more manageable chunks. Identifying discrete phases has various advantages:

Clone, Build, Test, Packaging, and Deployment are all examples of typical phases in the CI/CD lifecycle.

A pipeline stage can be made up of many pipeline steps.

10. Step

A pipeline step specifies a single build task and what should occur. A pipeline stage often encompasses several pipeline phases.

11. Workspace

A dedicated file system directory where build work for the current pipeline or build process is conducted. When debugging builds, this directory and its subdirectory structure are useful to investigate. The workspace will be generated on the build agent that the pipeline or build job is configured to run on.

12. Downstream

This refers to another pipeline or build job that will be triggered as a result of the current pipeline or build job.

13. Upstream

This job refers to the pipeline that started the current pipeline or build job.

Jenkins Configuration

A blog post on how to install Jenkins on AWS can be found here.

Remember to save the ”initialAdminPassword” value for the first time you log in.

text

text

To install commonly used plugins, select Install suggested plugins:

text

After downloading the plugins, enter your credentials and click ”Save and Continue” to access your dashboard.

text

PROJECTS

Now that we’ve covered the fundamentals of Jenkins, let’s get our hands dirty with some tasks and projects from the #90DaysofDevops challenge, which runs from Day 22 to Day 29.

Create a sample freestyle pipeline that prints “Hello World!!

  1. Using the Freestyle project, make a new object. Give it a name, for example, HelloBuildJob. On the bottom right, click OK.
  2. After you’ve created the project, go to the Configuration area and then to the ”Build Steps” section, where you’ll add the ”Execute Shell” option.

text

  1. Add the shell command to print “Hello World!!” echo "Hello World!!

text

  1. Save

  2. Now, click the ”Build Now” button. If everything is in order, you will see a green tick with the #1 next to it, indicating that the first build was successful.

text

  1. Click on the build number and look for the ”Hello World” text on the Console page.

text

That concludes the first project!

Task-01

We will start first by creating an agent for our app. We will create a Jenkins freestyle project for this task.

text

text

text

docker build -t todoapp .
docker run -d --name todoapp_c -p 8000:8000 todoapp

text

text

text

Task 02

text

text

The container has been launched as seen below:

text

That’s it for today!!!👋

Today we created our very first job with Jenkins our CI tool. We also looked at some simple jobs that we created using Jenkins.

For our next article, we will create a complete CI/CD Project with Jenkins as our CI tool.

Thank you for taking the time to read this! If you like the article, please clap (up to 50 times!) and connect with me on LinkedIn and Medium to remain up to speed on my future articles. 😅

Did you like this post? Check out my latest blog posts:

Maven on EC2
28 Jul 2023

Installing Maven on Ec2 Instance

  • aws
  • maven
  • cloud
Complete CICD Pipeline Java with Jenkins, Nexus, Sonar and AWS services
27 Jul 2023

From Code to Deployment - A Complete CICD journey for Java Apps using Jenkins, Nexus, Sonarqube, AWS ECR & ECS

  • devops
  • aws
  • cicd
Person typing on a laptop
21 Jul 2023

🏗️How to Make Animated ✨GIFs✨ For Amazon Web Services (AWS) Architectures:🏗️ A Step-by-Step Tutorial🏗️

  • aws
  • powerpoint
  • infra
  • resume