Thông tin tài liệu
www.it-ebooks.info
Jenkins Continuous
Integration Cookbook
Over 80 recipes to maintain, secure, communicate,
test, build, and improve the software development
process with Jenkins
Alan Mark Berg
BIRMINGHAM - MUMBAI
www.it-ebooks.info
Jenkins Continuous Integration Cookbook
Copyright © 2012 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, without the prior written permission of the publisher,
except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers
and distributors will be held liable for any damages caused or alleged to be caused directly or
indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies
and products mentioned in this book by the appropriate use of capitals. However, Packt
Publishing cannot guarantee the accuracy of this information.
First published: June 2012
Production Reference: 1080612
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-849517-40-9
www.packtpub.com
Cover Image by Faiz Fattohi (faizfattohi@gmail.com)
www.it-ebooks.info
Credits
Author
Alan Mark Berg
Reviewers
Dr. Alex Blewitt
Florent Delannoy
Michael Peacock
Acquisition Editor
Usha Iyer
Lead Technical Editor
Azharuddin Shaikh
Technical Editors
Merin Jose
Lubna Shaikh
Copy Editor
Brandt D'Mello
Project Coordinator
Leena Purkait
Proofreader
Jonathan Todd
Indexers
Tejal Daruwale
Hemangini Bari
Production Coordinator
Arvindkumar Gupta
Cover Work
Arvindkumar Gupta
www.it-ebooks.info
About the Author
Alan Mark Berg, Bsc, MSc, PGCE, has been the lead developer at the Central Computer
Services at the University of Amsterdam for the last 12 years. In his famously scarce spare
time, he writes. Alan has a degree, two Master's, and a teaching qualication. He has also
co-authored two books about Sakai (
http://sakaiproject.org)—a highly successful
open source learning management platform used by many millions of students around the
world. Alan has also won a Sakai Fellowship.
In previous incarnations, Alan was a technical writer, an Internet/Linux course writer, a
product line development ofcer, and a teacher. He likes to get his hands dirty with the
building and gluing of systems. He remains agile by ruining various development and
acceptance environments.
I would like to thank Hester, Nelson, and Lawrence. I felt supported and
occasionally understood by my family. Yes, you may pretend you don't know
me, but you do. Without your unwritten understanding that 2 a.m. is a
normal time to work and a constant supply of sarcasm is good for my soul,
I would not have nished this or any other large-scale project.
Finally, I would like to warmly thank the Packt Publishing team, whose
consistent behind the scenes effort improved the quality of this book.
www.it-ebooks.info
About the Reviewers
Dr. Alex Blewitt is a technical architect, working at an investment bank in London. He has
recently won an Eclipse Community Award at EclipseCon 2012 for his involvement with the
Eclipse platform over the last decade. He also writes for InfoQ and has presented at many
conferences. In addition to being an expert in Java, he also develops for the iOS platform, and
when the weather's nice, he goes ying. His blog is at http://alblue.bandlem.com, and
he can be reached via @alblue on Twitter.
Florent Delannoy is a French software engineer, now living in New Zealand after
graduating with honors from a MSc in Lyon. Passionate about open source, clean code,
and high quality software, he is currently working on one of New Zealand's largest domestic
websites with Catalyst I.T. in Wellington.
I would like to thank my family for their support and my colleagues
at Catalyst for providing an amazingly talented, open, and supportive
workplace.
www.it-ebooks.info
Michael Peacock (www.michaelpeacock.co.uk) is an experienced senior/lead
developer and Zend Certied Engineer from Newcastle, UK, with a degree in Software
Engineering from the University of Durham.
After spending a number of years running his own web agency, managing the development
team, and working for Smith Electric Vehicles on developing its web-based vehicle telematics
platform, he currently serves as head developer for an ambitious new start-up: leading the
development team and managing the software development processes.
He is the author of Drupal 7 Social Networking, PHP 5 Social Networking, PHP 5 E-Commerce
Development, Drupal 6 Social Networking, Selling online with Drupal E-Commerce, and
Building Websites with TYPO3. Other publications in which Michael has been involved include
Mobile Web Development and Drupal for Education and E-Learning, both of which he acted as
technical reviewer for.
Michael has also presented at a number of user groups and conferences including PHPNE,
PHPNW10, CloudConnect, and ConFoo,
You can follow Michael on Twitter: www.twitter.com/michaelpeacock, or nd out more
about him through his blog: www.michaelpeacock.co.uk.
www.it-ebooks.info
www.PacktPub.com
Support les, eBooks, discount offers, and more
You might want to visit www.PacktPub.com for support les and downloads related to
your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub
les available? You can upgrade to the eBook version at
www.PacktPub.com and as a print
book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
service@packtpub.com for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up
for a range of free newsletters and receive exclusive discounts and offers on Packt books
and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book
library. Here, you can access, read, and search across Packt's entire library of books.
Why Subscribe?
f Fully searchable across every book published by Packt
f Copy and paste, print, and bookmark content
f On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access
PacktLib today and view nine entirely free books. Simply use your login credentials for
immediate access.
www.it-ebooks.info
www.it-ebooks.info
Table of Contents
Preface 1
Chapter 1: Maintaining Jenkins 7
Introduction 8
Using a sacricial Jenkins instance 9
Backing up and restoring 13
Modifying Jenkins conguration from the command line 18
Reporting overall disc usage 21
Deliberately failing builds through log parsing 24
A Job to warn about the disc usage violations through log parsing 27
Keeping in contact with Jenkins through Firefox 30
Monitoring through JavaMelody 32
Keeping a track of the script glue 36
Scripting the Jenkins command-line interface 37
Global modications of Jobs with Groovy 40
Signaling the need to archive 42
Chapter 2: Enhancing Security 45
Introduction 45
Testing for OWASP's top ten security issues 47
Finding 500 errors and XSS attacks in Jenkins through fuzzing 50
Improving security via small conguration changes 53
Looking at the Jenkins user through Groovy 56
Working with the Audit Trail plugin 58
Installing OpenLDAP with a test user and group 61
Using Script Realm authentication for provisioning 64
Reviewing project-based matrix tactics via a custom group script 67
Administering OpenLDAP 70
Conguring the LDAP plugin 74
www.it-ebooks.info
[...]... 15 Select Install Guest additions using the Devices menu option 16 Add the Jenkins user to the vboxsf group sudo gedit /etc/group vboxsf:x:1001 :Jenkins 11 www.it-ebooks.info Maintaining Jenkins 17 Modify the JENKINS_ HOME variable in /etc/default /Jenkins to point to the mounted shared directory: sudo gedit /etc/default /Jenkins JENKINS_HOME=/media/sf_workspacej 18 On the host OS, create the directory... even be better if you still add tutorials to the Jenkins community wiki 8 www.it-ebooks.info Chapter 1 Signing up to the community To add community bug reports, or to modify wiki pages, you will need to create an account at the following URL: https://wiki .jenkins- ci.org/display /JENKINS/ Issue+Tracking Using a sacrificial Jenkins instance Continuous Integration (CI) servers are critical in the creation... jenkins. war –help A wider range of installation instructions can be found at https://wiki .jenkins- ci.org/display /JENKINS/ Installing +Jenkins For a more advanced recipe describing how to set up a virtual image under VirtualBox with Jenkins, you can use the Using a sacrificial Jenkins instance recipe in Chapter 1, Maintaining Jenkins Who this book is for This book is for Java developers, software architects,... environment variable JENKINS_ HOME to the directory you wish Jenkins to run under Next, run a command similar to the following: Java –jar jenkins. war –httpsPort=8443 –httpPort=-1 Jenkins will start to run over https on port 8443 The http port is turned off by setting httpPort=-1, and the terminal will display logging information You can ask for help through the following command: Java –jar jenkins. war –help... Considering test automation as a software project Offsetting work to Jenkins nodes 309 310 311 iii www.it-ebooks.info Table of Contents Learning from history Test frameworks are emerging Starve QA/ integration servers And there's always more Final comments 311 312 313 313 314 Index 315 iv www.it-ebooks.info Preface Jenkins is a Java-based Continuous Integration (CI) server that supports the discovery of defects... violations ff Keeping in contact with Jenkins through Firefox ff Monitoring through JavaMelody ff Keeping a track of the script glue ff Scripting the Jenkins command-line interface ff Global modifications of Jobs with Groovy ff Signaling the need to archive www.it-ebooks.info Maintaining Jenkins Introduction Jenkins is feature-rich and is vastly extendable through plugins Jenkins talks with numerous external... cloud Jenkins can use Amazon services or an Application Service Provider (ASP), such as CloudBees (http://www.cloudbees.com/) ff There is no fuss in installation, as installation is as simple as running only a single download file named jenkins. war ff It has over 400 plugins supporting communication, testing, and integration to numerous external applications (https://wiki .jenkins- ci.org/display /JENKINS/ Plugins)... collaborate ff Improve code, write plugins (https://wiki .jenkins- ci.org/display /JENKINS/ Help+Wanted) ff Test Jenkins, especially the plugins, and write bug reports, donating your test plans ff Improve documentation by writing tutorials and case studies ff Sponsor and support events 2 www.it-ebooks.info Preface What this book covers Chapter 1, Maintaining Jenkins, describes common maintenance tasks, such as... folders will fail without any visual warning The default Jenkins instance now needs a little reconfiguration: ff The jenkins user needs to belong to the the vboxsf group to have permission to use the shared folder ff The /etc/init.d /jenkins startup script points to /etc/default /jenkins and picks up the values of specific properties, such as JENKINS_ HOME Next, you added a shared folder to the guest... the Jenkins log file /var/log /jenkins/ jenkins.log, for *NIX distributions and for log-level SEVERE For example: SEVERE: Cannot perform a backup Please be sure jenkins/ hudson has write privileges in the configured backup path {0} 16 www.it-ebooks.info Chapter 1 Testing exclude patterns The following Perl script will allow you to test the exclude pattern Simply replace the $content value with your Jenkins . software development
process with Jenkins
Alan Mark Berg
BIRMINGHAM - MUMBAI
www.it-ebooks.info
Jenkins Continuous Integration Cookbook
Copyright © 2012 Packt. www.it-ebooks.info
Jenkins Continuous
Integration Cookbook
Over 80 recipes to maintain, secure, communicate,
test,
Ngày đăng: 06/03/2014, 23:20
Xem thêm: Jenkins Continuous Integration Cookbook doc, Jenkins Continuous Integration Cookbook doc