Jenkins
Jenkins
➢ Jenkin is an open-source project written in Java that runs on windows, macOS and other
unix like os. It is free, community supported and might be your first-choice tool for CI.
➢ Jenkins automate the entire s/w development life cycle.
➢ Jenkins was originally developed by sun microsystem in 2004 under the name hadson.
➢ The project was later named Jenkins when oracle bought microsystem.
➢ It can run on any major platform without any compatibility issues.
➢ Whenever developer write code, we integrate all that code of all developers at that point
of time and we build test and deliver/ deploy to the client. This process is called as
CI/CD.
➢ Jenkins helps us to achieve this.
➢ Because of CI now bugs will be reported fast and get rectified fast. So that entire
software development happens fast.
Workflow of Jenkins:
➢ We can attach git, maven, selenium and artifactory plugins to Jenkins.
➢ Once developers put codes in github Jenkins pill that code and send to maven for build.
➢ Once build is done, then Jenkins will pull that code and send to artifactory as per
requirement and so on.
➢ We can also deploy with Jenkins.
Advantages of Jenkins:
➢ It has lots of plugins available.
➢ You can write your own plugins.
➢ You can use community plugins.
➢ Jenkins is not just a tool. It is a framework i.e you can do whatever you want. All you
need is plugins.
➢ We ca attach slaves (nodes) to jenkins master. It instructs other (slaves) to do job. If
slaves are not available, Jenkins itself does the job.
➢ Jenkins also behave as crone server replacement i.e can do scheduled task.
➢ It can create labels.
CI/CD Project:
Go to google chrome – search ‘git download’ – download 2.31.1 for windows – click to
download.
Git download and install:
Open the download file preamble – c:\programfiles\gir – select components – select start menu
folder – choosing default editor vim – let git decide – git from the command line and also from
the 3rd party s/w – use the open SSL library – check as-is, commit unix-style line encodings –
use minty – choose default behavior – git credentials manager core – enable file system caching
– install.
Go to command prompt in laptop
- Git config –global username ‘username’
- Git config –global user.email ‘mailid’
- Git config –global –list
Scheduled Project:
Click on any project – configure – build triggers – build periodically - * * * * * - save
Can see automatic builds after every 1 min.
You can manually trigger build as well.
Source Code Polling (Poll SCM):
Now go to Jenkins home page – go to mymavenproject – configure
Now go to build trigger
Enable poll SCM
Schedule * * * * * - save
Now go to github account – do some changes in README.md – commit changes.
You can see after 1 min, it builds automatically.
User Management:
go to Jenkins homepage – manage Jenkins – manage user
create two users – Bhupinder and Rajput
now login as Bhupinder
{by default you have all the permissions}
Login as ‘admin’ again
Go to manage Jenkins – manage plugins – search ‘role-based authorization strategy’ – install
without restart.
Go to Jenkins homepage – manage Jenkins – configure global security – select role-based
strategy – save.
Login as ‘bhupinder’ – access denied
Now attach permission
Go to Jenkins – manage Jenkins – manage and assign role – manage roles
Role to add – employee
Go to item project – add developer and tester [pattern – dev* test*]
Then assign roles
User/group to add Bhupinder and Rajput.
How to install Jenkins on Ubuntu:
➢ Login into AWS account and create one ubuntu instance.
➢ Access it through putty and login as ‘ubuntu’.
➢ Use given commands
# sudo apt-get update
# sudo apt-cache search openjdk
#sudo apt-get install openjdk-8-jdk
#java -version
#sudo vi /etc/apt/source.list
Paste at the bottom
deb https://pkg.jenkins.io/debian-stablebinary/
#sudo apt-get update
# wget -q -o ---
# sudo apt-cache search Jenkins
# sudo apt-cache Madison Jenkins
# sudo apt-get install Jenkins -y
# sudo service Jenkins status -q
Copy public ip from AWS and paste in chrome url – public:8080
Go to instance #sudo cat /var/lib;initialpassword