DevOps Classroom Series – 28/Nov/2021

Continuous Integration/Delivery/Deployment using CI/CD Engines

  • Importance of Day builds and Night Builds
  • During the build process
    • Get the current latest version from git
    • Build/Package the code
      • This is technology specific
        • Java => ANT, MAVEN, GRADLE
        • Dotnet => msbuild
        • nodejs => Gulp
        • python
        • ruby
      • Possible outcomes:
        • Build Successful
        • Build failed
    • Run the unit-tests => Technology specific
      • Possible outcomes:
        • Unit tests passed
        • Unit tests failed
    • Static Code Analysis => Many options
      • Possible outcomes:
        • We might get corrections that can be made
        • All the code is good
  • Hint: As a DevOPs Engineer the minimum knowledge which you need to have is
    • How to execute build/packaging the code (from command line)
    • How to run unit tests (from command line)
    • How to perform static code analysis

Jenkins

  • History:

  • Versions:

    • 1.x
    • 2.x
  • Install Jenkins:

    • Overview
    • Lab Setup: Create an ubuntu 20.04 VM (free tier eligible)
    • Installation Steps : Refer Here
      • Install java 11
      sudo apt update
      sudo apt-cache search openjdk #to find the java packages
      sudo apt install openjdk-11-jdk -y
      java -version
      
      • Install jenkins LTS
      curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo tee \
      /usr/share/keyrings/jenkins-keyring.asc > /dev/null
      echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
      https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
      /etc/apt/sources.list.d/jenkins.list > /dev/null
      sudo apt-get update
      sudo apt-get install jenkins
      
      • To install a specific version of jenkins Refer Here
      • After installing jenkins on a linux machine a user called as jenkins is created
        • The home directory of this user is /var/lib/jenkins
      • Configuring Jenkins:
        • Navigate to http://publicip:8080
  • Installation steps for centos/redhat

sudo yum search openjdk
sudo yum install java-11-openjdk-devel -y
sudo wget -O /etc/yum.repos.d/jenkins.repo   https://pkg.jenkins.io/redhat-stable/jenkins.repo --no-check-certificate
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
sudo yum upgrade
sudo yum install epel-release -y
sudo yum install jenkins -y
sudo systemctl daemon-reload
sudo systemctl status jenkins.service
sudo systemctl enable jenkins.service
sudo systemctl start jenkins.service

  • If i want to run some commands periodically on a server or laptop,
    • Windows => Scheduler
    • Linux => Cron Job
  • Jenkins is a Cron/Scheduler on Steriods fine tuned for Continuous Integration and Continuous Deployment

Jenkins Core concepts

  • In Jenkins to create a pipeline we would create a jenkins Job/Project

  • Create a New project

  • In the job/project which we have configure the commands which we specified are

    • whoami => This will tell as which user is jenkins running the commands on the server
    • pwd => from which directory is jenkins working
  • Lets see build results

  • From these results we can claim when we execute jenkins job, the commands are executed as jenkins user and the current working directory is /var/lib/jenkins/workspace/hellojenkins

  • What this means is running from jenkins is

    • login into the server as jenkins user and execute the commands
    • SO we can simulate the same
  • Now lets add some more steps to build

  • Now to simulate this failure try to login into linux system as jenkins user and then check the output

  • here the command is asking for password, so jenkins has failed the job

  • Plugin is an addon to jenkins, which provides functionality on the jenkins ui

    • Installing plugin is not equal to installing software on the jenkins server
    • Now in this server git plugin is installed

Leave a comment

Turn on JavaScript to leave a comment.

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

Please turn AdBlock off
Social Media Widget Powered by Acurax Web Development Company
Exit mobile version
%%footer%%