SlideShare uma empresa Scribd logo
1 de 48
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Jenkins tutorial
Jenkins tutorialJenkins tutorial
Jenkins tutorial
 
Jenkins Introduction
Jenkins IntroductionJenkins Introduction
Jenkins Introduction
 
Jenkins
JenkinsJenkins
Jenkins
 
Jenkins
JenkinsJenkins
Jenkins
 
An Introduction To Jenkins
An Introduction To JenkinsAn Introduction To Jenkins
An Introduction To Jenkins
 
Jenkins for java world
Jenkins for java worldJenkins for java world
Jenkins for java world
 
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
 
What is Jenkins | Jenkins Tutorial for Beginners | Edureka
What is Jenkins | Jenkins Tutorial for Beginners | EdurekaWhat is Jenkins | Jenkins Tutorial for Beginners | Edureka
What is Jenkins | Jenkins Tutorial for Beginners | Edureka
 
Jenkins Tutorial.pdf
Jenkins Tutorial.pdfJenkins Tutorial.pdf
Jenkins Tutorial.pdf
 
Hacking Jenkins
Hacking JenkinsHacking Jenkins
Hacking Jenkins
 
CI/CD with Github Actions
CI/CD with Github ActionsCI/CD with Github Actions
CI/CD with Github Actions
 
Jenkins Pipelines
Jenkins PipelinesJenkins Pipelines
Jenkins Pipelines
 
Jenkins to Gitlab - Intelligent Build-Pipelines
Jenkins to Gitlab - Intelligent Build-PipelinesJenkins to Gitlab - Intelligent Build-Pipelines
Jenkins to Gitlab - Intelligent Build-Pipelines
 
A prentation on github
A prentation on githubA prentation on github
A prentation on github
 
Jenkins-CI
Jenkins-CIJenkins-CI
Jenkins-CI
 
Getting started with Jenkins
Getting started with JenkinsGetting started with Jenkins
Getting started with Jenkins
 
Introduction to Github Actions
Introduction to Github ActionsIntroduction to Github Actions
Introduction to Github Actions
 
Github
GithubGithub
Github
 
Introduction to GitHub Actions
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub Actions
 
CICD with Jenkins
CICD with JenkinsCICD with Jenkins
CICD with Jenkins
 

Semelhante a Jenkins 101: Getting Started

Semelhante a Jenkins 101: Getting Started (20)

Aucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricksAucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricks
 
Capistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient wayCapistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient way
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy System
 
Workflow story: Theory versus Practice in large enterprises by Marcin Piebiak
Workflow story: Theory versus Practice in large enterprises by Marcin PiebiakWorkflow story: Theory versus Practice in large enterprises by Marcin Piebiak
Workflow story: Theory versus Practice in large enterprises by Marcin Piebiak
 
Workflow story: Theory versus practice in Large Enterprises
Workflow story: Theory versus practice in Large EnterprisesWorkflow story: Theory versus practice in Large Enterprises
Workflow story: Theory versus practice in Large Enterprises
 
Moving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventuresMoving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventures
 
Splunk n-box-splunk conf-2017
Splunk n-box-splunk conf-2017Splunk n-box-splunk conf-2017
Splunk n-box-splunk conf-2017
 
#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible
 
Introducing Ansible
Introducing AnsibleIntroducing Ansible
Introducing Ansible
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidence
 
NginX - good practices, tips and advanced techniques
NginX - good practices, tips and advanced techniquesNginX - good practices, tips and advanced techniques
NginX - good practices, tips and advanced techniques
 
Puppet Camp Seattle 2014: Docker and Puppet: 1+1=3
Puppet Camp Seattle 2014: Docker and Puppet: 1+1=3 Puppet Camp Seattle 2014: Docker and Puppet: 1+1=3
Puppet Camp Seattle 2014: Docker and Puppet: 1+1=3
 
(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines
 
Docker and Containers for Development and Deployment — SCALE12X
Docker and Containers for Development and Deployment — SCALE12XDocker and Containers for Development and Deployment — SCALE12X
Docker and Containers for Development and Deployment — SCALE12X
 
The Fairy Tale of the One Command Build Script
The Fairy Tale of the One Command Build ScriptThe Fairy Tale of the One Command Build Script
The Fairy Tale of the One Command Build Script
 
Capistrano, Puppet, and Chef
Capistrano, Puppet, and ChefCapistrano, Puppet, and Chef
Capistrano, Puppet, and Chef
 
Kubernetes laravel and kubernetes
Kubernetes   laravel and kubernetesKubernetes   laravel and kubernetes
Kubernetes laravel and kubernetes
 
Plone deployment made easy
Plone deployment made easyPlone deployment made easy
Plone deployment made easy
 
Os dev tool box
Os dev tool boxOs dev tool box
Os dev tool box
 
Jenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
Jenkins Days - Workshop - Let's Build a Pipeline - Los AngelesJenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
Jenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
 

Último

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Último (20)

Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 

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