Jenkins: The Definitive Guide

Book description

Streamline software development with Jenkins, the popular Java-based open source tool that has revolutionized the way teams think about Continuous Integration (CI). This complete guide shows you how to automate your build, integration, release, and deployment processes with Jenkins—and demonstrates how CI can save you time, money, and many headaches.

Ideal for developers, software architects, and project managers, Jenkins: The Definitive Guide is both a CI tutorial and a comprehensive Jenkins reference. Through its wealth of best practices and real-world tips, you'll discover how easy it is to set up a CI service with Jenkins.

  • Learn how to install, configure, and secure your Jenkins server
  • Organize and monitor general-purpose build jobs
  • Integrate automated tests to verify builds, and set up code quality reporting
  • Establish effective team notification strategies and techniques
  • Configure build pipelines, parameterized jobs, matrix builds, and other advanced jobs
  • Manage a farm of Jenkins servers to run distributed builds
  • Implement automated deployment and continuous delivery

Publisher resources

View/Submit Errata

Table of contents

  1. Foreword
  2. Preface
    1. Audience
    2. Book Layout
    3. Jenkins or Hudson?
    4. Font Conventions
    5. Command-Line Conventions
    6. Contributors
    7. The Review Team
    8. Book Sponsors
      1. Wakaleo Consulting
      2. CloudBees
      3. Odd-e
    9. Using Code Examples
    10. Safari® Books Online
    11. How to Contact Us
    12. Acknowledgments
  3. 1. Introducing Jenkins
    1. Introduction
    2. Continuous Integration Fundamentals
    3. Introducing Jenkins (née Hudson)
    4. From Hudson to Jenkins—A Short History
    5. Should I Use Jenkins or Hudson?
    6. Introducing Continuous Integration into Your Organization
      1. Phase 1—No Build Server
      2. Phase 2—Nightly Builds
      3. Phase 3—Nightly Builds and Basic Automated Tests
      4. Phase 4—Enter the Metrics
      5. Phase 5—Getting More Serious About Testing
      6. Phase 6—Automated Acceptance Tests and More Automated Deployment
      7. Phase 7—Continuous Deployment
    7. Where to Now?
  4. 2. Your First Steps with Jenkins
    1. Introduction
    2. Preparing Your Environment
      1. Installing Java
      2. Installing Git
      3. Setting Up a GitHub Account
      4. Configuring SSH Keys
      5. Forking the Sample Repository
    3. Starting Up Jenkins
    4. Configuring the Tools
      1. Configuring Your Maven Setup
      2. Configuring the JDK
      3. Notification
      4. Setting Up Git
    5. Your First Jenkins Build Job
    6. Your First Build Job in Action
    7. More Reporting—Displaying Javadocs
    8. Adding Code Coverage and Other Metrics
    9. Conclusion
  5. 3. Installing Jenkins
    1. Introduction
    2. Downloading and Installing Jenkins
    3. Preparing a Build Server for Jenkins
    4. The Jenkins Home Directory
    5. Installing Jenkins on Debian or Ubuntu
    6. Installing Jenkins on Red Hat, Fedora, or CentOS
    7. Installing Jenkins on SUSE or OpenSUSE
    8. Running Jenkins as a Stand-Alone Application
    9. Running Jenkins Behind an Apache Server
    10. Running Jenkins on an Application Server
    11. Memory Considerations
    12. Installing Jenkins as a Windows Service
    13. What’s in the Jenkins Home Directory
    14. Backing Up Your Jenkins Data
    15. Upgrading Your Jenkins Installation
    16. Conclusion
  6. 4. Configuring Your Jenkins Server
    1. Introduction
    2. The Configuration Dashboard—The Manage Jenkins Screen
    3. Configuring the System Environment
    4. Configuring Global Properties
    5. Configuring Your JDKs
    6. Configuring Your Build Tools
      1. Maven
      2. Ant
      3. Shell-Scripting Language
    7. Configuring Your Version Control Tools
      1. Configuring Subversion
      2. Configuring CVS
    8. Configuring the Mail Server
    9. Configuring a Proxy
    10. Conclusion
  7. 5. Setting Up Your Build Jobs
    1. Introduction
    2. Jenkins Build Jobs
    3. Creating a Freestyle Build Job
      1. General Options
      2. Advanced Project Options
    4. Configuring Source Code Management
      1. Working with Subversion
      2. Working with Git
        1. Installing the plugin
          1. System-wide configuration of the plugin
          2. SSH key setup
        2. Using the plugin
          1. Advanced per-project source code management configuration
          2. Branches to build
          3. Excluded regions
          4. Excluded users
          5. Checkout/merge to local branch
          6. Local subdirectory for repo
          7. Merge before build
          8. Prune remote branches before build
          9. Clean after checkout
          10. Recursively update submodules
          11. Use commit author in changelog
          12. Wipe out workspace
          13. Choosing strategy
          14. Git executable
          15. Repository browser
        3. Build triggers
          1. Gerrit Trigger
        4. Post-build actions
          1. Push only if build succeeds
          2. Merge results
          3. Tags
          4. Branches
        5. GitHub plugin
    5. Build Triggers
      1. Triggering a Build Job Once Another Build Job Has Finished
      2. Scheduled Build Jobs
      3. Polling the SCM
      4. Triggering Builds Remotely
      5. Manual Build Jobs
    6. Build Steps
      1. Maven Build Steps
      2. Ant Build Steps
      3. Executing a Shell or Windows Batch Command
      4. Using Jenkins Environment Variables in Your Builds
      5. Running Groovy Scripts
      6. Building Projects in Other Languages
    7. Post-Build Actions
      1. Reporting on Test Results
      2. Archiving Build Results
      3. Notifications
      4. Building Other Projects
    8. Running Your New Build Job
    9. Working with Maven Build Jobs
      1. Building Whenever a SNAPSHOT Dependency Is Built
      2. Configuring the Maven Build
      3. Post-Build Actions
      4. Deploying to an Enterprise Repository Manager
      5. Deploying to Commercial Enterprise Repository Managers
      6. Managing Modules
      7. Extra Build Steps in Your Maven Build Jobs
    10. Using Jenkins with Other Languages
      1. Building Projects with Grails
      2. Building Projects with Gradle
        1. The Gradle plugin for Jenkins
        2. Incremental builds
      3. Building Projects with Visual Studio MSBuild
      4. Building Projects with NAnt
      5. Building Projects with Ruby and Ruby on Rails
    11. Conclusion
  8. 6. Automated Testing
    1. Introduction
    2. Automating Your Unit and Integration Tests
    3. Configuring Test Reports in Jenkins
    4. Displaying Test Results
    5. Ignoring Tests
    6. Code Coverage
      1. Measuring Code Coverage with Cobertura
        1. Integrating Cobertura with Maven
        2. Integrating Cobertura with Ant
        3. Installing the Cobertura code coverage plugin
        4. Reporting on code coverage in your build
        5. Interpreting code coverage metrics
      2. Measuring Code Coverage with Clover
    7. Automated Acceptance Tests
    8. Automated Performance Tests with JMeter
    9. Help! My Tests Are Too Slow!
      1. Add More Hardware
      2. Run Fewer Integration/Functional Tests
      3. Run Your Tests in Parallel
    10. Conclusion
  9. 7. Securing Jenkins
    1. Introduction
    2. Activating Security in Jenkins
    3. Simple Security in Jenkins
    4. Security Realms—Identifying Jenkins Users
      1. Using Jenkins’s Built-in User Database
      2. Using an LDAP Repository
      3. Using Microsoft Active Directory
      4. Using Unix Users and Groups
      5. Delegating to the Servlet Container
      6. Using Atlassian Crowd
      7. Integrating with Other Systems
    5. Authorization—Who Can Do What
      1. Matrix-based Security
        1. Setting up matrix-based security
        2. Fine-tuning user permissions
        3. Help! I’ve locked myself out!
      2. Project-based Security
      3. Role-based Security
    6. Auditing—Keeping Track of User Actions
    7. Conclusion
  10. 8. Notification
    1. Introduction
    2. Email Notification
    3. More Advanced Email Notification
    4. Claiming Builds
    5. RSS Feeds
    6. Build Radiators
    7. Instant Messaging
      1. IM Notification with Jabber
      2. IM Notification using IRC
    8. IRC Notification
    9. Desktop Notifiers
    10. Notification via Notifo
    11. Mobile Notification
    12. SMS Notification
    13. Making Noise
    14. Extreme Feedback Devices
    15. Conclusion
  11. 9. Code Quality
    1. Introduction
    2. Code Quality in Your Build Process
    3. Popular Java and Groovy Code Quality Analysis Tools
      1. Checkstyle
      2. PMD/CPD
      3. FindBugs
      4. CodeNarc
    4. Reporting on Code Quality Issues with the Violations Plugin
      1. Working with Freestyle Build Jobs
      2. Working with Maven Build Jobs
    5. Using the Checkstyle, PMD, and FindBugs Reports
    6. Reporting on Code Complexity
    7. Reporting on Open Tasks
    8. Integrating with Sonar
    9. Conclusion
  12. 10. Advanced Builds
    1. Introduction
    2. Parameterized Build Jobs
      1. Creating a Parameterized Build Job
      2. Adapting Your Builds to Work with Parameterized Build Scripts
      3. More Advanced Parameter Types
      4. Building from a Subversion Tag
      5. Building from a Git Tag
      6. Starting a Parameterized Build Job Remotely
      7. Parameterized Build Job History
    3. Parameterized Triggers
    4. Multiconfiguration Build Jobs
      1. Setting Up a Multiconfiguration Build
      2. Configuring a Slave Axis
      3. Configuring a JDK Axis
      4. Custom Axis
      5. Running a Multiconfiguration Build
    5. Generating Your Maven Build Jobs Automatically
      1. Configuring a Job
      2. Reusing Job Configuration with Inheritance
      3. Plugin Support
      4. Freestyle Jobs
    6. Coordinating Your Builds
      1. Parallel Builds in Jenkins
      2. Dependency Graphs
      3. Joins
      4. Locks and Latches
    7. Build Pipelines and Promotions
      1. Managing Maven Releases with the M2Release Plugin
      2. Copying Artifacts
      3. Build Promotions
      4. Aggregating Test Results
      5. Build Pipelines
    8. Conclusion
  13. 11. Distributed Builds
    1. Introduction
    2. The Jenkins Distributed Build Architecture
    3. Master/Slave Strategies in Jenkins
      1. The Master Starts the Slave Agent Using SSH
      2. Starting the Slave Agent Manually Using Java Web Start
      3. Installing a Jenkins Slave as a Windows Service
      4. Starting the Slave Node in Headless Mode
      5. Starting a Windows Slave as a Remote Service
    4. Associating a Build Job with a Slave or Group of Slaves
    5. Node Monitoring
    6. Cloud Computing
      1. Using Amazon EC2
        1. Setting up your Amazon EC2 build farm
        2. Using EC2 instances as part of your build farm
        3. Using dynamic instances
    7. Using the CloudBees DEV@cloud Service
    8. Conclusion
  14. 12. Automated Deployment and Continuous Delivery
    1. Introduction
    2. Implementing Automated and Continuous Deployment
      1. The Deployment Script
      2. Database Updates
      3. Smoke Tests
      4. Rolling Back Changes
    3. Deploying to an Application Server
      1. Deploying a Java Application
        1. Using the Deploy plugin
        2. Redeploying a specific version
        3. Deploying a version from a previous Jenkins build
        4. Deploying a version from a Maven repository
      2. Deploying Scripting-based Applications Like Ruby and PHP
    4. Conclusion
  15. 13. Maintaining Jenkins
    1. Introduction
    2. Monitoring Disk Space
      1. Using the Disk Usage Plugin
      2. Disk Usage and the Jenkins Maven Project Type
    3. Monitoring the Server Load
    4. Backing Up Your Configuration
      1. Fundamentals of Jenkins Backups
      2. Using the Backup Plugin
      3. More Lightweight Automated Backups
    5. Archiving Build Jobs
    6. Migrating Build Jobs
    7. Conclusion
  16. A. Automating Your Unit and Integration Tests
    1. Automating Your Tests with Maven
    2. Automating Your Tests with Ant
  17. Index
  18. About the Author
  19. Colophon
  20. Copyright

Product information

  • Title: Jenkins: The Definitive Guide
  • Author(s): John Ferguson Smart
  • Release date: July 2011
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449305352