- Installing Jenkins on Centos Refer Here
sudo yum install wget -y sudo wget -O /etc/yum.repos.d/jenkins.repo \ https://pkg.jenkins.io/redhat-stable/jenkins.repo sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key sudo yum upgrade # Add required dependencies for the jenkins package sudo yum install java-11-openjdk -y sudo yum install jenkins -y sudo systemctl daemon-reload sudo systemctl enable jenkins sudo systemctl start jenkins
- Project: This is where we configure jenkins to do some activity (ci/cd pipeline).
- Free Style Project: This is project which was present in jenkins from day 1, It relies on UI elements provided.
- UI: Jenkins Plugin provides additional UI elements to minimize the work.
- Jenkins Home Directory: Jenkins stores all the information about the projects, jobs, plugins etc in the home directory of jenkins. If we consider taking backup of jenkins, its all about backing up jenkins home directory
- WorkSpace: Workspace is the folder that stores all the files folders etc created during job execution.
Experiment 1: Create a new Jenkins Project hello-jenkins
- Lets create a job called as hello-jenkins
- cd into /var/lib/jenkins/jobs and execute tree command
- Let preview config.xml
<?xml version='1.1' encoding='UTF-8'?> <project> <actions/> <description></description> <keepDependencies>false</keepDependencies> <properties/> <scm class="hudson.scm.NullSCM"/> <canRoam>true</canRoam> <disabled>false</disabled> <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> <triggers/> <concurrentBuild>false</concurrentBuild> <builders> <hudson.tasks.Shell> <command>whoami pwd</command> <configuredLocalRules/> </hudson.tasks.Shell> </builders> <publishers/> <buildWrappers/>
- Now lets build the project and review the jenkins home directory jobs folder
- Change the build steps
- Build the project and review the
Activity 1: Building a Java Project
- Lets build spring pet clinic again using jenkins free style project
Understanding Distributed Build Concept
- Jenkins build execute on Nodes. Each node has executors which define number of jobs that can be executed on a node
Nodes are of two types
- Master Node:
- Responsible for hosting jenkins UI and distributing jobs, managing users, plugins etc
- Ideally Not a good idea to run jobs on master apart from maintenace jobs
- For every project/every technology/os types organizations add nodes to the master.
- When we add nodes number of executors increase which in turn means we can manage multiple projects from same jenkins server.
- Master Node:
- Since we have a jenkins server which is linux based, lets create one more node which is also linux.
- To communicate from one linux node to other linux node, we use ssh.
- Lets use the same concept for configuring node to master
- Node which we have configure takes username and password as credentials.
- Now Manage Jenkins => Nodes
- Now build the project