DevOps Classroom Series – 10/Jul/2021

Exploring Jenkins

  • So lets get started by installing jenkins. Refer Here
  • Today we will be using a linux machine to install jenkins which has ubuntu distribution
  • This setup will be done on AWS with 2 vCPUs and 8 GB of RAM
  • Jenkins History Preview
  • Installing Jenkins on Ubuntu 18.04:
    • Login into the jenkins using ssh
    • Lets see the list of users on the linux machine Preview
    • To install jenkins we need to java installed for java requirements Refer Here
    • Lets try to install java 11 Preview
    • Install by executing the command sudo apt install openjdk-11-jdk -y
    • Install jenkins by executing the below commands
    sudo apt update
    wget -q -O - | sudo apt-key add -
    sudo sh -c 'echo deb binary/ > \
    sudo apt-get update
    sudo apt-get install jenkins
    • Now lets see the list of the users Preview
    • A New user called as jenkins is created and the home directory of this user is /var/lib/jenkins
    • Jenkins runs on port 8080 so navigate to http://<public-ip&gt;:8080
    • Follow the installation steps as discussed in the classroom. Preview

Basic Jenkins Terminology

  • Project/Job: This is where we define the steps to be executed.

Exploring & understanding

  • Steps Preview Preview Preview Preview Preview Preview Preview Preview
  • When i run/build a project in jenkins it is running as a newly created jenkins user
  • So jenkins is nothing but a scheduler which runs the linux commands as some linux user.
  • To make the life simple, jenkins creates some ui components which are friendly towards building a project (CI/CD)

Manual Scenario 1

  • Cloning the project from git. For this lets take a project called as spring pet clinic Refer Here

  • To clone a project from git we require

    • git to be installed
    • probably internet connection
    • some disk space
  • Create a Jenkins job and in the build step type git clone command.

What is Jenkins Plugin

  • Lets try to clone the spring pet clinic repository as mentioned above
  • Lets look at git plugin Preview
  • plugin is a UI developed which will translate into low level commands. These UI will help in doing the job easily.

Lets try to build java 11 project

  • clone the git repository Refer Here and cd into java-11-projects then execute
mvn package
  • To make this command work install maven
sudo apt install maven -y
  • If we can execute the command manually on the linux machine it will work from jenkins as well.

Lets try to execute sudo commands from jenkins

  • The commands to be executed are
sudo apt update
  • Lets create the jenkins job Preview
  • The Status is Preview Preview
  • Just because commands work on the system doesnot mean they will work from jenkins. To evaluate whether they work or not we need to work with jenkins user
  • Now added jenkins user to sudoers file with NOPASSWD option

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin