SlideShare a Scribd company logo
CI Server Configuration : Jenkins 
    
Continuous integration 
 
Continuous integration (CI) is the practice, in software engineering, of merging all 
developer working copies with a shared mainline several times a day. It was first named and 
proposed by Grady Booch in his method, who did not advocate integrating several times a day.. 
The main aim of CI is to prevent integration problems, referred to as "integration hell". 
 
CI was originally intended to be used in combination with automated unit tests written 
through the practices of test­driven development. Initially this was conceived of as running all 
unit tests in the developer's local environment and verifying they all passed before committing to 
the mainline. This helps avoid one developer's work in progress breaking another developer's 
copy. Later elaborations of the concept introduced build servers, which automatically run the 
unit tests periodically or even after every commit and report the results to the developers. 
 
 
Best practices 
 
1 Maintain a code repository 
2 Automate the build 
3 Make the build self­testing 
4 Everyone commits to the baseline every day 
5 Every commit (to baseline) should be built 
6 Keep the build fast 
7 Test in a clone of the production environment 
8 Make it easy to get the latest deliverables 
9 Everyone can see the results of the latest build 
10 Automate deployment 
 
 
Costs and benefits 
 
Continuous integration is intended to produce benefits such as: 
 
Integration bugs are detected early and are easy to track down due to small change 
sets. This saves both time and money over the lifespan of a project. 
 
Avoids last­minute chaos at release dates, when everyone tries to check in their slightly 
incompatible versions 
 
When unit tests fail or a bug emerges, if developer need to revert the codebase to a 
bug­free state without debugging, only a small number of changes are lost (because integration 
happens frequently) 
Constant availability of a "current" build for testing, demo, or release purposes 
Frequent code check­in pushes developers to create modular, less complex 
code[citation needed] 
 
With continuous automated testing benefits can include: 
 
Enforces discipline of frequent automated testing 
Immediate feedback on system­wide impact of local changes 
Metrics generated from automated testing and CI (such as metrics for code coverage, 
code complexity, and features complete) focus developers on developing functional, quality 
code, and help develop momentum in a team 
 
 
  Installing Jenkins on ubuntu 
 
Installation: 
For installation follow below steps: 
1.  ​wget ­q ­O ­ https://jenkins­ci.org/debian/jenkins­ci.org.key | sudo apt­key add ­ 
2.  ​sudo sh ­c 'echo deb http://pkg.jenkins­ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list' 
3.  ​sudo apt­get update 
4.  sudo apt­get install jenkins 
 
Upgrade: 
Once installed like this, you can update to the later version of Jenkins (when it comes out) by 
running the following commands: 
1. sudo apt­get update 
2. sudo apt­get install jenkins 
 
 
 
 
 
 
 
 
 
 
Configure Jenkins: 
Next, you need to use the Jenkins web interface to install plugins, configure security and add 
users. 
 
Open your web browser to ​http://localhost:8080​. (If you’re running Jenkins remotely, you 
should be able to use the server’s domain or IP address.) 
 
currently for ip: ​x.x.x.x  
credential 
username: yourUserName 
pass: yourPassword 
 
Install Plugins:  
From the root page, click ​“Manage Jenkins”​ then ​“Manage Plugins”​. From the ​“Available” 
tab, check the following plugins: 
 
1. Git 
2. GitHub 
3. rbenv Or rvm 
4. Rake 
5. Rcov 
6. RubyMetrics plugin 
7. Mailer 
 
Next, select ​“Download now and install after restart” 
 
Configuration of Global Security part is skipped. You can see details here ​Security 
 
Manage Jenkins: 
 
Step 1: ​ Go to yourip:jenkinport/configure (​http://x.x.x.x:8080/configure​) . You can do it by jenkin 
home ­> manage jenkins ­> configure system 
 
Step 2:   
Home   
check home directory is /var/lib/jenkins or not . otherwise you have to set all 
default home configuration to that particular home directory. 
 
Email notification  
 
1. go to yourjenkinserver/configure  
2. In Email notification block smtp server => smtp.gmail.com 
3. select Use SMTP Authentication 
4. give user name password, select use ssh, smtp port => 465 , chracter­set => 
UTF­8 
5. select ​Test configuration by sending test e­mail ​to check configuration is 
succesful or not . 
6. If fails follow it from above link. 
7. Finally under your project settings , In ​Post­build Actions ​in  ​Email notification 
set up your emails. 
Configure Global Security
1. Enable security. 
2. Security Realm ­> Jenkins’ own user database ­> Allow users to sign up 
3. Authorization ­> Anyone can do anything 
4. after you sign up  ­> change authorization to​ Logged­in users can do anything or 
Matrix­based security or Project­based Matrix Authorization Strategy  ​as your wish 
. in Matrix­based security​ you can set up configuration for a particular user/ group 
which is created in jenkins ui ​. 
 
N.B.​ while configuring global security  you may have security problem like locking yourself 
(Hope you have not  :) ). 
but If you , then​ ​Disable Security 
 
or for your convenience  
One may accidentally set up security realm / authorization in such a way that you may no longer 
able to reconfigure Jenkins. 
When this happens, you can fix this by the following steps: 
1. Stop Jenkins (the easiest way to do this is to kill the servlet container.) 
2. Go to $JENKINS_HOME in the file system and find config.xml file. 
3. Open this file in the editor. 
4. Look for the <useSecurity>true</useSecurity> element in this file. 
5. Replace true with false 
6. Remove the elements authorizationStrategy and securityRealm 
7. Start Jenkins 
When Jenkins comes back, it's in the unsecured mode where everyone gets full access to the 
system. 
If this is still not working, trying renaming or deleting config.xml. 
 
 
 
   
Configure your project: 
Next, you need to configure your Rails project. To complete this follow below steps: 
 
Step 1:​ From the Jenkins home page, click on ​“New Item”​, then select “Build a free­style 
software project” and click “OK”. 
 
Step 2: ​Fill in the “​Project Name”​ and “​GitHub project” ​fields.” Project Name” must be a single 
word. 
 
Step 3: ​Under “​Source Code Management”,​ select “​Git”​ and fill in the repo url. (If you need to 
authenticate with SSH, configure that here.) 
   ​Step 3.1: 
      ​You need to switch jenkins user to generate ssh key by following command: 
su ­s /bin/bash jenkins 
It is because jenkins web interface expect all command will be executed as 
a bash command. Hence whenever we executing by switching only by su jenkins 
then it’s environment will not same as the jenkins expect. So that the known host 
will not allow the user to clone the remote private repository. 
 
Step 4:​ Check the “​rbenv build wrapper”​ box. 
 
If you are using ​RVM​ instead of ​RBENV then, 
Check the  ​Run the build in a RVM­managed environment =>Implementation  
put ruby version for that project​. 
 
Step 5:​  Database credential need to configure to sync the code with jenkin. So that we need to 
create database.yml . To do so, follow the below command: 
 
touch ~/project­database.yml 
 
Then you need to write your db config in  ​~/project­database.yml ​according to your Database 
configuration. To accomplish that follow: 
 
         ​nano ~/project­database.yml 
 
and put your custom configuration in ​~/project­database.yml 
 
Step 6: 
Tick on  ​Build when a change is pushed to GitHub ​from​ Build Triggers 
 
Step 7:​ Under “​Add build step​”, select “​Execute shell”.  
 
Now we are ready and a typical Rails app script might look like this: 
cp ~/project­database.yml config/database.yml 
mkdir ­p coverage/rcov 
mkdir ­p rcov 
bundle install 
rake db:create RAILS_ENV=test 
rake db:migrate RAILS_ENV=test 
rake spec 
 
Make sure the database is configured properly. If you need a special database.yml, you can 
store this in Jenkins’ home directory. 
 
OPTIONAL: ​To make sure you know when a build fails, set up email notifications (under 
“Add post­build action”). Configure SMTP on the “Configure System” page, found under 
“Manage Jenkins”. See the Jenkins wiki for ​an easy Gmail setup:  
Or You can follow below step. 
8. got to yourjenkinserver/configure  
9. In Email notification block smtp server => smtp.gmail.com 
10. select Use SMTP Authentication 
11. give user name password, select use ssh, smtp port => 465 , chracter­set => 
UTF­8 
12. select ​Test configuration by sending test e­mail ​to check configuration is 
succesful or not . 
13. If fails follow it from above link. 
14. Finally under your project settings , In ​Post­build Actions ​in  ​Email notification 
set up your emails. 
 
Post­build Actions 
1. select publlish rcov report 
2. set directory => coverage/rcov 
3. Also before do this you need to ensure that you have right gem in your gem file: 
  gem 'simplecov', :require => false, :group => :test 
  gem 'simplecov­rcov' 
4. And also configure your spec/spec_helper.rb like this: 
               ​ require 'simplecov' 
                require 'simplecov­rcov' 
                SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter 
                SimpleCov.start 'rails' 
 
 
Try out your build by clicking “​Build Now”​. 
 
 
GitHub Integration 
 
Finally, I'll set up the GitHub integration, so that a push triggers a new build in Jenkins. 
 
Navigate to “​Webhooks & Services​” under “​Settings”​ on the GitHub repository page. 
You’ll need to be a repo admin to do this. 
 
Click “​Configure services​” and select the “​Jenkins (GitHub plugin)” ​option. 
 
Enter the address to your Jenkins server followed by ​/github­webhook/​ (for example 
http://psdd.t.proxylocal.com​/github­webhook/​   or ​http://​x.x.x.x:8080/​github­webhook/​ ​), check 
“Active” and update your settings. 
 
That’s it. Try it out by pushing a commit to GitHub and verifying that a new build is triggered in 
Jenkins. 
 
 
    HardwareRequirementsForJenkins
 
As for your hardware questions we do not typically recommend best practices or hardware 
configurations because these vary based off specific customer needs and these are considered 
consulting questions. Jenkins Enterprise by definition runs exactly the same as OSS Jenkins. 
Here are some generic guidelines we sent out to a specific customer that has a sizable config: 
The machine requirements on Jenkins installations differ based on the artifacts generated. 
Thus, there is no one­size fits all recommendation that we provide. However, here are some 
guidelines: 
1. Everything runs off JENKINS_HOME, so make sure there is enough disk space 
available and the disk can grow. If you run out of disk space, you will see failures. Some 
plugins take more space than others (e.g a report generating plugin vs a build plugin). 
The disk usage plugin helps determine usage. 
2. Have a beefy machine for Jenkins master & do not run slaves on the master machine. 
Every slave has certain memory allocated in the master JVM, so the bigger the RAM for 
the master, the better it is. We typically hear customers allocate 16G or so. 
3. Slaves tend to be run of the mill x86 boxes, typically you want them to have the same 
OS as the release platforms. 
For reference,​ ​this​ presentation from Redhat shares their typical memory/machine 
requirements. 
As for the HA feature this is simply two (or more) masters sharing the same 
JENKINS_HOME—you can read more about the plugin​ ​here​. 
 
To Force restart jenkins 
1. sometimes jenkins goes out of memory exception.  ​sudo service jenkins restart 
donot work then . to we have to kill the java process manually . 
2. sudo netstat ­lpn | grep :8080 # jenkins run on 8080 port 
3. sudo kill ­9 pid 
4. sudo service jenkins start 
 
 
User id  / Password  for test purpose 
user : jenkins 
password : yourPassword 
 
 
               ============== ​THANK YOU ​=============== 
 

More Related Content

PPTX
Continuous Integration for Beginners
PPTX
Keeping Your CI/CD Pipeline as Fast as It Needs to Be
PPT
Continuous integration
PPTX
Continuous integration with Jenkins
PPTX
Introduction to Continuous Integration with Jenkins
PPTX
Jumping from Continuous Integration to Continuous Delivery with Jenkins Enter...
PPTX
Jenkins - From Continuous Integration to Continuous Delivery
PDF
Yale Jenkins Show and Tell
Continuous Integration for Beginners
Keeping Your CI/CD Pipeline as Fast as It Needs to Be
Continuous integration
Continuous integration with Jenkins
Introduction to Continuous Integration with Jenkins
Jumping from Continuous Integration to Continuous Delivery with Jenkins Enter...
Jenkins - From Continuous Integration to Continuous Delivery
Yale Jenkins Show and Tell

What's hot (20)

PDF
Jfokus 2017 - The DevOps Disaster
PDF
Jenkins CI
PDF
Devops | CICD Pipeline
PPTX
Jenkins Introduction
ZIP
Continuous Integration, Build Pipelines and Continuous Deployment
PPT
Part 2 improving your software development v1.0
PDF
Continuous integration and delivery
PPTX
Flusso Continuous Integration & Continuous Delivery
PPTX
Continuous integration using jenkins
PPTX
不只自動化而且更敏捷的Android開發工具 gradle
PDF
Jenkins tutorial
PPTX
Jenkins CI
PPTX
Dev-QA-Ops UNICOM WCNGT 2014 Bangalore
PDF
Standardizing Jenkins with CloudBees Jenkins Team
PDF
Let’s start Continuous Integration with jenkins
PPTX
Continuous integration
PDF
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
PPT
Continuous Integration (Jenkins/Hudson)
PDF
Introducing CI/CD to Engineering Teams - By: Matt Brunsdon
PDF
OpenTuesday: Aktuelle Standards der agilen Softwareentwicklung
Jfokus 2017 - The DevOps Disaster
Jenkins CI
Devops | CICD Pipeline
Jenkins Introduction
Continuous Integration, Build Pipelines and Continuous Deployment
Part 2 improving your software development v1.0
Continuous integration and delivery
Flusso Continuous Integration & Continuous Delivery
Continuous integration using jenkins
不只自動化而且更敏捷的Android開發工具 gradle
Jenkins tutorial
Jenkins CI
Dev-QA-Ops UNICOM WCNGT 2014 Bangalore
Standardizing Jenkins with CloudBees Jenkins Team
Let’s start Continuous Integration with jenkins
Continuous integration
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
Continuous Integration (Jenkins/Hudson)
Introducing CI/CD to Engineering Teams - By: Matt Brunsdon
OpenTuesday: Aktuelle Standards der agilen Softwareentwicklung
Ad

Viewers also liked (15)

PPTX
Урок БП: Параллели истории
PDF
Kansalaisopistot somessa
PPT
WeTalk 01, English Environment, 20160507
DOCX
Raghavendra Prasad Reddy_resume
PDF
farouk cv ..
PDF
Vy Le_Goldman Sachs Stock Valuatio Project
PDF
Oppimisen tilat – näkökulmia tulevaisuuden kouluun ja oppilaitosrakentamiseen
PPTX
Medialunas de panaderia
PPTX
Necesidades educativas especiales
DOCX
Mohamed Abdel Aziz CV 2015
PDF
第4回 Machine Learning 15minutes!
PPTX
Genres Of Music During Spanish Time
DOC
s.chand-CURRICULUM VITAE
PPTX
TALLER NECESIDADES EDUCATIVAS ESPECIALES
PPTX
Placenta y Membranas Fetales
Урок БП: Параллели истории
Kansalaisopistot somessa
WeTalk 01, English Environment, 20160507
Raghavendra Prasad Reddy_resume
farouk cv ..
Vy Le_Goldman Sachs Stock Valuatio Project
Oppimisen tilat – näkökulmia tulevaisuuden kouluun ja oppilaitosrakentamiseen
Medialunas de panaderia
Necesidades educativas especiales
Mohamed Abdel Aziz CV 2015
第4回 Machine Learning 15minutes!
Genres Of Music During Spanish Time
s.chand-CURRICULUM VITAE
TALLER NECESIDADES EDUCATIVAS ESPECIALES
Placenta y Membranas Fetales
Ad

Similar to JenkinsCIdocumentations-removedcredentials.docx (20)

PDF
Continuous Integration - What even is it?
PPTX
Lets talk about CI CD Pipeline in Agile
PPTX
Continuous Delivery concept overview. Continuous Integration Systems. DevOps ...
PDF
Continuous Integration Approach
PPTX
Software engineering
PPT
CI and CD with Jenkins
PPTX
Devops insights
PPT
Continuous Integration
PPTX
Continous integration and delivery for single page applications
PPTX
What is Continuous Integration and Continuous Delivery
PDF
Flight East 2018 Presentation–Continuous Integration––An Overview
PDF
CI/CD (DevOps) 101
PPTX
Using Continuous Integration To Ensure Project Health New
PDF
Continuous integration and delivery for java based web applications
PPTX
Introducing Continuous Integration Using Vsts
PDF
How to win at DevOps (and understand it along the way)
PPTX
Continuous integration
PDF
Enabling Agile Testing Through Continuous Integration Agile2009
PDF
Continuous Everything
PPTX
Contineous integration
Continuous Integration - What even is it?
Lets talk about CI CD Pipeline in Agile
Continuous Delivery concept overview. Continuous Integration Systems. DevOps ...
Continuous Integration Approach
Software engineering
CI and CD with Jenkins
Devops insights
Continuous Integration
Continous integration and delivery for single page applications
What is Continuous Integration and Continuous Delivery
Flight East 2018 Presentation–Continuous Integration––An Overview
CI/CD (DevOps) 101
Using Continuous Integration To Ensure Project Health New
Continuous integration and delivery for java based web applications
Introducing Continuous Integration Using Vsts
How to win at DevOps (and understand it along the way)
Continuous integration
Enabling Agile Testing Through Continuous Integration Agile2009
Continuous Everything
Contineous integration

JenkinsCIdocumentations-removedcredentials.docx