Day-22 : Getting Started with Jenkins 😃

Day-22 : Getting Started with Jenkins 😃

Linux, Git, Git-Hub, Docker is finished, so let's learn the key tools to deploy CICD tool:

What is Jenkins?

  • Jenkins is an open-source continuous integration-continuous delivery and deployment (CI/CD) automation software DevOps tool written in the Java programming language. It is used to implement CI/CD workflows, called pipelines.

  • Jenkins is a tool that is used for automation, and it is an open-source server that allows all the developers to build, test and deploy software. It works or runs on Java as it is written in Java. By using Jenkins we can make a continuous integration of projects(jobs) or end-to-endpoint automation.

  • Jenkins achieves Continuous Integration with the help of plugins. Plugins allow the integration of Various DevOps and DevSecOps stages. If you want to integrate a particular tool, you need to install the plugins for that tool. For example Git, Maven 2 project, Amazon EC2, HTML publisher,Sonarqube, Prometheus etc.

Let us discuss the necessity of this tool before going ahead to the procedural part for installation:

  • Nowadays, humans are becoming lazy😴 day by day so even having digital screens and just one click button in front of us also need some automation.

  • Here, I’m referring to that part of automation where we need not have to look upon a process(here called a job) for completion and after it do another job. For that, we have Jenkins with us.

Note: By now Jenkins should be installed on your machine(as it was a part of previous tasks, if not follow Installation Guide) or you can refre this blog also https://hashnode.com/draft/656b0a5fec13179b146e96ae

Tasks:

What you understood in Jenkin, write a small article in your own words (Don't copy from Internet Directly)

  • Jenkins is a powerful automation server used for continuous integration and continuous delivery (CI/CD) processes. It's an open-source tool designed to automate various tasks involved in building, testing, and deploying software applications.

  • Jenkins acts as the backbone of CI/CD pipelines, streamlining the development workflow by automating repetitive tasks, thereby improving productivity and software quality.

  1. Continuous Integration (CI): Jenkins enables developers to integrate their code changes into a shared repository regularly. It automates the build process and runs tests each time new code is committed, allowing teams to detect issues early in the development cycle.

  2. Continuous Delivery/Deployment (CD): Jenkins facilitates the automation of deploying applications to different environments, such as staging or production, after successful builds and tests. It helps in delivering software changes reliably and efficiently.

  3. Pipelines: Jenkins uses pipelines to define workflows as code. Pipeline scripts (written in Groovy DSL or declarative syntax) orchestrate the entire software delivery process, incorporating stages like build, test, and deployment, allowing for complex, customizable workflows.

Create a freestyle pipeline to print "Hello World!!"

  • Launch your instance in AWS and set up the Jenkins server on your instance using these commands.

sudo apt-get update && sudo apt-get upgrade -y
sudo apt update
sudo apt install fontconfig openjdk-17-jre
java -version
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
  https://pkg.jenkins.io/debian/jenkins.io-2023.key
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
  https://pkg.jenkins.io/debian binary/ | sudo tee \
  /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins
  • Allow inbound traffic on port 8080 for Jenkins in the AWS security group.

  • Open a new tab and enter your AWS IP address followed by ':8080'. It will prompt you for a password to access your Jenkins server. Use this command to retrieve the password.

sudo cat <red link>

  • After pasting your password, click on 'Install Plugins' to initiate the plugin installation. Create your Jenkins account and the Jenkins dashboard will open.

Follow these steps to create a freestyle pipeline that prints 'Hello World!!'.

  • Step 1: Click on a new item, and then you will have a page on which you have to give your name to your job and choose ‘freestyle project’ or any other option according to your need and then click ‘ok’.

  • Step 2: After this, you will reach a page where you have different options(like build, build triggers, and source code management) that help you manage your job.

  • Step 3: Now, we will give some description of our job.

  • Step 4: Now, you have to provide which source code management tool you are using since here we are not using anyone so will choose the ‘none’ option.

  • Step 5: After this, if you want to give some triggers then you can choose accordingly even Jenkins provides us scheduled triggers. And you can choose to build an environment also accordingly. But, here we are making a simple job, so we are not using any triggers and build environment options.

  • Step 6: In the build section we have an option ‘Execute shell’ by which we can write some command or code.

  • Step 7: Now, you can give the command according to your need.
echo "Hello friends this is my jenkins demo: %date : %time"

Then click apply and save. So, your job is created.

  • Step 8: Now, we will run it for which click the ‘build now’ option and a building history will be created then click on it.

  • Step 9: Now, Click on console output, and you can see your output. Also, by console output, you can see whether your job has failed or been successful.


Happy Learning

Thanks For Reading! :)

-DevOpsParthu💝💥