SlideShare a Scribd company logo
Jenkins 101: Getting Started
By
R. Geoffrey Avery
FOSSCON – Philadelphia 2016
YAPC::EU – Cluj 2016
What is Jenkins
● Tool for continuous integration/development
● A fork from Hudson
● Fire jobs manually, on a schedule, on commit
● Uses Java and Tomcat to do its work
● In same game as TravisCI
Install Jenkins
sudo wget -q -O - https://jenkins-ci.org/debian/jenkins-
ci.org.key | apt-key add -
sudo apt-get install jenkins
#------
sudo wget -O /etc/yum.repos.d/jenkins.repo
http://pkg.jenkins-ci.org/redhat/jenkins.repo
sudo rpm --import https://jenkins-ci.org/redhat/jenkins-
ci.org.key
sudo yum install jenkins
● https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins
A new Jenkins
Manage Jenkins
Configure Node
● If you are on a small server Nerf these or
provide more resources
Manage Jenkins
How to add users
● https://wiki.jenkins-ci.org/display/JENKINS/Standard+Security+Setup
● Make sure your user has powers before you deny everyone full power
Get to adding users
● Manage Jenkins → Configure Global Security
Enable Security
● Turn on security
● Let Jenkins manage
● Anyone can still get in
(don't lock yourself
out)
Become a User
● Go create yourself a user
Enable Matrix Security
● Pick matrix
● Add yourself
● Give yourself full power
Plugins
● Jenkins supports many plugins to add features
● Can generally install new plugin without a
restart
● To upgrade or remove a restart usually needed
HTML Publisher Plugin
● https://wiki.jenkins-ci.org/display/JENKINS/HTML+Publisher+Plugin
Add Plugin
Approve the plugin
More good plugins
https://wiki.jenkins-ci.org/display/JENKINS/
● NodeLabel+Parameter+Plugin
● Validating+String+Parameter+Plugin
● Git+Plugin (need git 1.7.9+)
Create a Job
Job to grep configurations
● Jenkins stores job as
…/jobs/jobname/config.xml
● Pain to search across many jobs
● This sample job will grep just config.xml files
● Will make html report of what is found
Live Demo Now
Schedule for Periodic Builds
This field follows the syntax of cron (with minor differences). Specifically, each line consists of 5
fields separated by TAB or whitespace:
MINUTE HOUR DOM MONTH DOW
MINUTE Minutes within the hour (0–59)
HOUR The hour of the day (0–23)
DOM The day of the month (1–31)
MONTH The month (1–12)
DOW The day of the week (0–7) where 0 and 7 are Sunday.
To specify multiple values for one field, the following operators are available. In the order of
precedence,
* specifies all valid values
M-N specifies a range of values
M-N/X or */X steps by intervals of X through the specified range or whole valid range
A,B,...,Z enumerates multiple values
To allow periodically scheduled tasks to produce even load on the system, the symbol H (for “hash”)
should be used wherever possible. For example, using 0 0 * * * for a dozen daily jobs will cause a
large spike at midnight. In contrast, using H H * * * would still execute each job once a day, but not
all at the same time, better using limited resources.
The H symbol can be used with a range. For example, H H(0-7) * * * means some time between 12:00 AM
(midnight) to 7:59 AM. You can also use step intervals with H, with or without ranges.
The H symbol can be thought of as a random value over a range, but it actually is a hash of the job
name, not a random function, so that the value remains stable for any given project.
Schedule for School Night
H H(6-11) * * 1-5
#Once each school night between 10pm-4am San Francisco /
1am-7am Wilmington / 6am-noon London (an hour later in
summer)
#If someone does something foolish on Friday or Saturday the
site won't be broken over the weekend because of the update
● Schedule jobs with a very cron like syntax
● Use 'H' to let jenkins pick for better distribution
Return to live demo
Add a slave node
● Not all work needs to or should run on master
● Slaves can be on same server or many
● Make a user (groupadd, useradd)
● Install Java (apt-get, yum, or ?)
● Setup ssh for connections...
Create ssh key for slave
jenkins@localhost:~$ mkdir .ssh
jenkins@localhost:~$ cd .ssh
jenkins@localhost:~/.ssh$ chmod 0700 .
jenkins@localhost:~/.ssh$ ssh-keygen -C "jenkins to slave mrprod"
-f jenkins_to_mrprod
jenkins@localhost:~/.ssh$ ls -aFl
total 16
drwx------ 2 jenkins jenkins 4096 Jun 1 12:53 ./
drwxr-xr-x 14 jenkins jenkins 4096 Jun 1 12:51 ../
-rw------- 1 jenkins jenkins 1679 Jun 1 12:53 jenkins_to_mrprod
-rw-r--r-- 1 jenkins jenkins 399 Jun 1 jenkins_to_mrprod.pub
.ssh/config
host sample-mrprod
hostname sample.dynalias.org
user mrprod
identityfile ~/.ssh/jenkins_to_mrprod
● Let the master call slave from command line
● Will need ForwardAgent and Proxy Command if
you need to tunnel through a middle box
Give ssh key to slave
root@localhost:/home/mrprod# sudo su mrprod
localhost:~> pwd
/home/mrprod
localhost:~> mkdir .ssh
localhost:~> chmod 0700 .ssh
localhost:~> cd .ssh
localhost:~/.ssh> touch authorized_keys
localhost:~/.ssh> chmod 0600 authorized_keys
#then put the public key in authorized_keys
● ssh will not work if you forget the chmod step
Add ssh key to jenkins
Add ssh key to jenkins (2)
Create a slave node
Make a label for nodes
Live Demo Now
Starting and Stopping
http://sample.dynalias.org:8080/quietDown
http://sample.dynalias.org:8080/cancelQuietDown
${JENKINSURL}/${ACTION}
#------
$ sudo /etc/init.d/jenkins restart
● Other valid choices for the ACTION: start|stop|status|restart|
force-reload
● A good idea to quietDown first so you don't stop jobs in progress
Thank You
Slides will be found at
http://platypiventures.com/perl/present
And the conference website
Slides of the Rigged Demo
These were replaced by the live demo
Job Name
Basic Job Settings
Add a Variable
What do you want to look for?
Pass through to grep
Advanced Job Settings
Source Code Settings
● Git needs a plugin
Add Code to Do Something
● Add a shell to do the real work. Today with bash, but
also supports Groovy and anything you can call
Script Part 1
#!/bin/bash
# make sure we have place to write the output
# if no directory build one, blow away a file it it is in the way
if [[ ! -d $WORKSPACE/output ]] ; then
if [[ -e $WORKSPACE/output ]] ; then
rm $WORKSPACE/output
fi
mkdir $WORKSPACE/output
fi
ls -aFlR $WORKSPACE
report="$WORKSPACE/output/found.html"
hostname
whoami
pwd
cd ../../jobs
pwd
echo "<h1>$Pattern</h1> ( $Settings )<hr>" > $report
Script Part 2
jenkinsgrep () {
for dir in * ; do
echo "nn--------------- $dir"
local results=$(grep $Settings $Pattern $dir/config.xml)
if [[ -n $results ]]; then
echo $results
# echo "<h2>$dir</h2>" >> $report
echo "<h2><a href='${JENKINS_URL}job/$dir/configure'>$dir</a></h2>" >> $report
echo "<pre>$results</pre>" >> $report
fi
done
}
jenkinsgrep
Add an HTML report
Configure the Report
The End (Again)
Check github for slides and the config.xml files for
the jobs discussed

More Related Content

PPT
Jenkins Overview
PDF
Jenkins
PPTX
Jenkins CI
PPTX
Introduction to jenkins
ODP
An Introduction To Jenkins
PPTX
Jenkins Introduction
PPTX
Jenkins presentation
PPTX
Jenkins CI presentation
Jenkins Overview
Jenkins
Jenkins CI
Introduction to jenkins
An Introduction To Jenkins
Jenkins Introduction
Jenkins presentation
Jenkins CI presentation

What's hot (20)

PPTX
PPTX
Jenkins tutorial
PDF
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
PDF
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
PDF
Introduction to DevOps Tools | DevOps Training | DevOps Tutorial for Beginner...
PPTX
Introduction to DevOps
PDF
Jenkins Pipelines
ODP
Introduction to Ansible
PPTX
Terraform modules restructured
PPTX
Jenkins tutorial for beginners
PDF
"DevOps > CI+CD "
PDF
Introduction to CICD
PPTX
Getting started with Jenkins
PDF
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
PPT
CI and CD with Jenkins
PPTX
Git branching strategies
PDF
Jenkins tutorial
PPTX
Jenkins for java world
PPTX
Introduction to CI/CD
Jenkins tutorial
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
Introduction to DevOps Tools | DevOps Training | DevOps Tutorial for Beginner...
Introduction to DevOps
Jenkins Pipelines
Introduction to Ansible
Terraform modules restructured
Jenkins tutorial for beginners
"DevOps > CI+CD "
Introduction to CICD
Getting started with Jenkins
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI and CD with Jenkins
Git branching strategies
Jenkins tutorial
Jenkins for java world
Introduction to CI/CD
Ad

Similar to Jenkins 101: Getting Started (20)

PPTX
Drupal Continuous Integration with Jenkins - The Basics
PPTX
Jenkins talk at Silicon valley DevOps meetup
PPTX
Using Jenkins for jobs scheduling
PDF
Continuous Integration using Jenkins with Python
PPTX
Drupal Continuous Integration with Jenkins - Deploy
PDF
Jenkins automation
ODP
Jenkins 101: Continuos Integration with Jenkins
PDF
Jenkins CI
PPT
Jenkins CI
PDF
Jenkins-CI
PDF
Hacking Jenkins
PDF
Jenkins hudsonci-101002103143-phpapp02
PDF
Jenkins Tutorial.pdf
PPTX
Building the Test Automation Framework - Jenkins for Testers
PDF
Jenkins - Automating Yourself Out Of A Job (One That You Don't Want)
PDF
Unix for developers
PPTX
Mule tcat server - automating tasks
PDF
Graduating to Jenkins CI for Ruby(-on-Rails) Teams
PDF
Scaling Jenkins Devops presentation
PDF
Take control of your Jenkins jobs via job DSL.
Drupal Continuous Integration with Jenkins - The Basics
Jenkins talk at Silicon valley DevOps meetup
Using Jenkins for jobs scheduling
Continuous Integration using Jenkins with Python
Drupal Continuous Integration with Jenkins - Deploy
Jenkins automation
Jenkins 101: Continuos Integration with Jenkins
Jenkins CI
Jenkins CI
Jenkins-CI
Hacking Jenkins
Jenkins hudsonci-101002103143-phpapp02
Jenkins Tutorial.pdf
Building the Test Automation Framework - Jenkins for Testers
Jenkins - Automating Yourself Out Of A Job (One That You Don't Want)
Unix for developers
Mule tcat server - automating tasks
Graduating to Jenkins CI for Ruby(-on-Rails) Teams
Scaling Jenkins Devops presentation
Take control of your Jenkins jobs via job DSL.
Ad

Recently uploaded (20)

PDF
System and Network Administration Chapter 2
PPTX
ai tools demonstartion for schools and inter college
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
ISO 45001 Occupational Health and Safety Management System
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PPT
Introduction Database Management System for Course Database
PPTX
Introduction to Artificial Intelligence
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Understanding Forklifts - TECH EHS Solution
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
System and Network Administraation Chapter 3
PDF
top salesforce developer skills in 2025.pdf
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
PTS Company Brochure 2025 (1).pdf.......
System and Network Administration Chapter 2
ai tools demonstartion for schools and inter college
CHAPTER 2 - PM Management and IT Context
Which alternative to Crystal Reports is best for small or large businesses.pdf
ISO 45001 Occupational Health and Safety Management System
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Introduction Database Management System for Course Database
Introduction to Artificial Intelligence
Design an Analysis of Algorithms II-SECS-1021-03
2025 Textile ERP Trends: SAP, Odoo & Oracle
Understanding Forklifts - TECH EHS Solution
How to Choose the Right IT Partner for Your Business in Malaysia
System and Network Administraation Chapter 3
top salesforce developer skills in 2025.pdf
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PTS Company Brochure 2025 (1).pdf.......

Jenkins 101: Getting Started

  • 1. Jenkins 101: Getting Started By R. Geoffrey Avery FOSSCON – Philadelphia 2016 YAPC::EU – Cluj 2016
  • 2. What is Jenkins ● Tool for continuous integration/development ● A fork from Hudson ● Fire jobs manually, on a schedule, on commit ● Uses Java and Tomcat to do its work ● In same game as TravisCI
  • 3. Install Jenkins sudo wget -q -O - https://jenkins-ci.org/debian/jenkins- ci.org.key | apt-key add - sudo apt-get install jenkins #------ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo sudo rpm --import https://jenkins-ci.org/redhat/jenkins- ci.org.key sudo yum install jenkins ● https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins
  • 6. Configure Node ● If you are on a small server Nerf these or provide more resources
  • 8. How to add users ● https://wiki.jenkins-ci.org/display/JENKINS/Standard+Security+Setup ● Make sure your user has powers before you deny everyone full power
  • 9. Get to adding users ● Manage Jenkins → Configure Global Security
  • 10. Enable Security ● Turn on security ● Let Jenkins manage ● Anyone can still get in (don't lock yourself out)
  • 11. Become a User ● Go create yourself a user
  • 12. Enable Matrix Security ● Pick matrix ● Add yourself ● Give yourself full power
  • 13. Plugins ● Jenkins supports many plugins to add features ● Can generally install new plugin without a restart ● To upgrade or remove a restart usually needed
  • 14. HTML Publisher Plugin ● https://wiki.jenkins-ci.org/display/JENKINS/HTML+Publisher+Plugin
  • 17. More good plugins https://wiki.jenkins-ci.org/display/JENKINS/ ● NodeLabel+Parameter+Plugin ● Validating+String+Parameter+Plugin ● Git+Plugin (need git 1.7.9+)
  • 19. Job to grep configurations ● Jenkins stores job as …/jobs/jobname/config.xml ● Pain to search across many jobs ● This sample job will grep just config.xml files ● Will make html report of what is found
  • 21. Schedule for Periodic Builds This field follows the syntax of cron (with minor differences). Specifically, each line consists of 5 fields separated by TAB or whitespace: MINUTE HOUR DOM MONTH DOW MINUTE Minutes within the hour (0–59) HOUR The hour of the day (0–23) DOM The day of the month (1–31) MONTH The month (1–12) DOW The day of the week (0–7) where 0 and 7 are Sunday. To specify multiple values for one field, the following operators are available. In the order of precedence, * specifies all valid values M-N specifies a range of values M-N/X or */X steps by intervals of X through the specified range or whole valid range A,B,...,Z enumerates multiple values To allow periodically scheduled tasks to produce even load on the system, the symbol H (for “hash”) should be used wherever possible. For example, using 0 0 * * * for a dozen daily jobs will cause a large spike at midnight. In contrast, using H H * * * would still execute each job once a day, but not all at the same time, better using limited resources. The H symbol can be used with a range. For example, H H(0-7) * * * means some time between 12:00 AM (midnight) to 7:59 AM. You can also use step intervals with H, with or without ranges. The H symbol can be thought of as a random value over a range, but it actually is a hash of the job name, not a random function, so that the value remains stable for any given project.
  • 22. Schedule for School Night H H(6-11) * * 1-5 #Once each school night between 10pm-4am San Francisco / 1am-7am Wilmington / 6am-noon London (an hour later in summer) #If someone does something foolish on Friday or Saturday the site won't be broken over the weekend because of the update ● Schedule jobs with a very cron like syntax ● Use 'H' to let jenkins pick for better distribution
  • 24. Add a slave node ● Not all work needs to or should run on master ● Slaves can be on same server or many ● Make a user (groupadd, useradd) ● Install Java (apt-get, yum, or ?) ● Setup ssh for connections...
  • 25. Create ssh key for slave jenkins@localhost:~$ mkdir .ssh jenkins@localhost:~$ cd .ssh jenkins@localhost:~/.ssh$ chmod 0700 . jenkins@localhost:~/.ssh$ ssh-keygen -C "jenkins to slave mrprod" -f jenkins_to_mrprod jenkins@localhost:~/.ssh$ ls -aFl total 16 drwx------ 2 jenkins jenkins 4096 Jun 1 12:53 ./ drwxr-xr-x 14 jenkins jenkins 4096 Jun 1 12:51 ../ -rw------- 1 jenkins jenkins 1679 Jun 1 12:53 jenkins_to_mrprod -rw-r--r-- 1 jenkins jenkins 399 Jun 1 jenkins_to_mrprod.pub
  • 26. .ssh/config host sample-mrprod hostname sample.dynalias.org user mrprod identityfile ~/.ssh/jenkins_to_mrprod ● Let the master call slave from command line ● Will need ForwardAgent and Proxy Command if you need to tunnel through a middle box
  • 27. Give ssh key to slave root@localhost:/home/mrprod# sudo su mrprod localhost:~> pwd /home/mrprod localhost:~> mkdir .ssh localhost:~> chmod 0700 .ssh localhost:~> cd .ssh localhost:~/.ssh> touch authorized_keys localhost:~/.ssh> chmod 0600 authorized_keys #then put the public key in authorized_keys ● ssh will not work if you forget the chmod step
  • 28. Add ssh key to jenkins
  • 29. Add ssh key to jenkins (2)
  • 31. Make a label for nodes
  • 33. Starting and Stopping http://sample.dynalias.org:8080/quietDown http://sample.dynalias.org:8080/cancelQuietDown ${JENKINSURL}/${ACTION} #------ $ sudo /etc/init.d/jenkins restart ● Other valid choices for the ACTION: start|stop|status|restart| force-reload ● A good idea to quietDown first so you don't stop jobs in progress
  • 34. Thank You Slides will be found at http://platypiventures.com/perl/present And the conference website
  • 35. Slides of the Rigged Demo These were replaced by the live demo
  • 39. What do you want to look for?
  • 42. Source Code Settings ● Git needs a plugin
  • 43. Add Code to Do Something ● Add a shell to do the real work. Today with bash, but also supports Groovy and anything you can call
  • 44. Script Part 1 #!/bin/bash # make sure we have place to write the output # if no directory build one, blow away a file it it is in the way if [[ ! -d $WORKSPACE/output ]] ; then if [[ -e $WORKSPACE/output ]] ; then rm $WORKSPACE/output fi mkdir $WORKSPACE/output fi ls -aFlR $WORKSPACE report="$WORKSPACE/output/found.html" hostname whoami pwd cd ../../jobs pwd echo "<h1>$Pattern</h1> ( $Settings )<hr>" > $report
  • 45. Script Part 2 jenkinsgrep () { for dir in * ; do echo "nn--------------- $dir" local results=$(grep $Settings $Pattern $dir/config.xml) if [[ -n $results ]]; then echo $results # echo "<h2>$dir</h2>" >> $report echo "<h2><a href='${JENKINS_URL}job/$dir/configure'>$dir</a></h2>" >> $report echo "<pre>$results</pre>" >> $report fi done } jenkinsgrep
  • 46. Add an HTML report
  • 48. The End (Again) Check github for slides and the config.xml files for the jobs discussed