You are previewing Mastering Jenkins.
O'Reilly logo
Mastering Jenkins

Book Description

Configure and extend Jenkins to architect, build, and automate efficient software delivery pipelines

About This Book

  • Configure and horizontally scale a Jenkins installation to support a development organization of any size
  • Implement Continuous Integration, Continuous Delivery, and Continuous Deployment solutions in Jenkins
  • A step-by-step guide to help you get the most out of the powerful automation orchestration platform that is Jenkins

Who This Book Is For

If you are a novice or intermediate-level Jenkins user who has used Jenkins before but are not familiar with architecting solutions and implementing it in your organization, then this is the book for you. A basic understanding of the core elements of Jenkins is required to make the best use of this book.

What You Will Learn

  • Create and manage various types of build jobs, and implement automation tasks to support a software project of any kind
  • Get to grips with the automated testing architecture, and scalable automated testing techniques
  • Facilitate the delivery of software across the SDLC by creating scalable automated deployment solutions
  • Manage scalable automation pipelines in Jenkins using the latest build, test, and deployment strategies
  • Implement a scalable master / slave build automation platform, which can support Windows, Mac OSX, and Linux software solutions
  • Cover troubleshooting and advanced configuration techniques for Jenkins slave nodes
  • Support a robust build and delivery system by implementing basic infrastructure as code solutions in configuration management tools such as Ansible

In Detail

With the software industry becoming more and more competitive, organizations are now integrating delivery automation and automated quality assurance practices into their business model. Jenkins represents a complete automation orchestration system, and can help converge once segregated groups into a cohesive product development and delivery team. By mastering the Jenkins platform and learning to architect and implement Continuous Integration, Continuous Delivery, and Continuous Deployment solutions, your organization can learn to outmanoeuvre and outpace the competition.

This book will equip you with the best practices to implement advanced continuous delivery and deployment systems in Jenkins. The book begins with giving you high-level architectural fundamentals surrounding Jenkins and Continuous Integration. You will cover the different installation scenarios for Jenkins, and see how to install it as a service, as well as the advanced XML configurations. Then, you will proceed to learn more about the architecture and implementation of the Jenkins Master/Save node system, followed by creating and managing Jenkins build jobs effectively. Furthermore, you’ll explore Jenkins as an automation orchestration system, followed by implementing advanced automated testing techniques. The final chapters describe in depth the common integrations to Jenkins from third-party tools such as Jira, Artifactory, Amazon EC2, and getting the most out of the Jenkins REST-based API.

By the end of this book, you will have all the knowledge necessary to be the definitive resource for managing and implementing advanced Jenkins automation solutions for your organization.

Style and approach

This book is a step-by-step guide to architecting and implementing automated build solutions, automated testing practices, and automated delivery methodologies. The topics covered are based on industry-proven techniques, and are explained in a simple and easy to understand manner.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the code file.

Table of Contents

  1. Mastering Jenkins
    1. Table of Contents
    2. Mastering Jenkins
    3. Credits
    4. Foreword
    5. About the Author
    6. About the Reviewers
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    8. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. The Website
        5. Questions
    9. 1. Setup and Configuration of Jenkins
      1. The Jenkins platform architecture and configuration techniques
      2. Jenkins on Microsoft Windows
        1. Configuring the JVM and Java arguments–port, JRE, and memory
      3. Jenkins on Linux and UNIX
        1. Configuring the JVM
      4. Running Jenkins behind an NGINX reverse proxy
      5. Running Jenkins behind an Apache reverse proxy
      6. Disaster recovery in Jenkins
        1. Jenkins snapshot backups
        2. Setting up a Jenkins mirror – rsync
      7. Jenkins on Mac OS X
        1. The Jenkins LTS release line
        2. Jenkins XML configuration files
      8. Summary
    10. 2. Distributed Builds – Master/Slave Mode
      1. Understanding the master and slave architecture
        1. Creating slave nodes in the UI
      2. Choosing a launch method
        1. Slave agent via Java Web Start
          1. Prerequisites
          2. The Jenkins Java Web Start launch page
            1. JavaWS via a web browser
            2. JavaWS via the command line
          3. Headless slave agents via the command line
        2. Slave agents on Windows via WMI and DCOM
          1. Troubleshooting Windows DCOM and CIFS errors
            1. Error – access denied
              1. Workaround 1
              2. Workaround 2
            2. Error – no more data available
              1. Workaround
        3. Slave agents via SSH tunneling
      3. Administering Jenkins slaves
        1. The node administration dashboard
        2. Preventative monitoring
        3. Managing individual slave nodes
      4. Labels, groups, and load balancing
        1. Attaching a slave to a group by creating a label
        2. Attaching a slave to many groups
        3. Restricting slave execution to global or tied jobs
        4. Jenkins plugins that support distributed builds
      5. Summary
    11. 3. Creating Views and Jobs in Jenkins
      1. The Jenkins user interface
        1. The main header
        2. The configuration panel
        3. The job table
        4. RSS feeds
        5. The Jenkins build queue and executor status panel
      2. Jobs in Jenkins
        1. Freestyle projects in Jenkins
          1. Project options
            1. Defining build parameters
          2. Advanced project options
          3. Source code management
            1. Source control via SVN
            2. Advanced SVN options
            3. Source control via Git–requires the Git plugin
            4. Additional behaviors
          4. Build triggers
          5. Build steps
          6. Post-build actions
        2. Maven projects
          1. Build triggers
          2. Build step
          3. Advanced options
          4. Post-build steps
        3. Monitoring external jobs
        4. Multiconfiguration jobs in Jenkins – matrix jobs
          1. Configuration matrix
          2. Slaves
          3. Label expression
          4. User-defined axes
      3. Creating views
        1. Filtering jobs by regular expression
      4. Summary
    12. 4. Managing Views and Jobs in Jenkins
      1. Managing Views in Jenkins
        1. Altering the default "View"
        2. Customizing the basic content of a View
        3. Advanced customization of a "Views" content
      2. Navigating a job's project page
        1. The Configuration panel
        2. The Build History panel
        3. The project overview – central panel
      3. Job execution
      4. The Job Execution Configuration panel
      5. The Status panel
      6. The Console Output
      7. Summary
    13. 5. Advanced Automated Testing
      1. Quality assurance initiatives and test automation terminology
      2. The Software Development Lifecycle
      3. Connecting product codes to tests
      4. Baking quality into the product
        1. Efficient automated test architecture
      5. Automated testing in Jenkins
      6. Unit tests in Jenkins through MSTest
        1. How to set up MSTest agents
        2. Running automated tests via MSTest
          1. A example MSTest execution
        3. Running MSTests and reporting the results in Jenkins
          1. Publishing test results in Jenkins
        4. Organizing test jobs
      7. Distributed testing solutions
        1. The Selenium Grid
        2. Parallel down-stream jobs
      8. Summary
    14. 6. Software Deployments and Delivery
      1. Standardizing build outputs
        1. Architecting a packaging scheme
      2. Implementing a Definitive Media Library
        1. Publishing assets to a DML
          1. Jenkins' archive the artifacts post-build action
          2. Publishing to Artifactory
          3. Publishing via Maven
          4. Pushing a Docker container
      3. Automated deployments
        1. Retrieving build artifacts and packages
          1. Fetching artifacts via archive artifacts
          2. Fetching artifacts from Artifactory
          3. Fetching artifacts via Maven
          4. Verifying package integrity
            1. Jenkins fingerprints
            2. MSBUILD via custom C# task
            3. Linux / Unix BASH script
        2. Executing deployment automation
        3. Leveraging Jenkins slave nodes for deployment
      4. Summary
    15. 7. Build Pipelines
      1. The value proposition of build pipelines
      2. Architecting a build pipeline
        1. The first segment of the build pipeline
        2. Additional pipeline segments
        3. The complete pipeline
        4. Visualizing the final pipeline
        5. Alterations for shrink-wrapped and embedded projects
      3. Implementing build pipelines in Jenkins
        1. Upstream jobs – triggered
        2. Downstream jobs – via post build actions
        3. The Parameterized Trigger plugin
        4. The Promoted build plugin
        5. The Post-Build Tasks plugin
        6. The Delivery Pipeline plugin
        7. Connecting two Jenkins instances – development and production
      4. Summary
    16. 8. Continuous Practices
      1. Kaizen – Continuous Improvement
        1. Kanban
      2. Continuous Integration
        1. What Continuous Integration is not
        2. Code-based branching techniques
          1. Branch by abstraction
        3. Feature toggles
        4. Fail fast and recover even faster
        5. Distributed Version Control
        6. Continuous Integration in Jenkins
          1. SCM polling
          2. Running a Jenkins job via the SVN post-commit hooks
            1. Windows–VBScript
            2. *Nix–Bash
          3. Triggering a Jenkins job via GitHub push
            1. Jenkins configurations
            2. GitHub configurations:
      3. Continuous Delivery
        1. The principles of Continuous Delivery
        2. Continuous Delivery in Jenkins
          1. Rapid feedback loops
          2. Quality gates and approvals
          3. Build pipeline workflow and visualization
      4. Continuous Deployment
        1. Continuous Deployment in Jenkins
      5. Summary
    17. 9. Integrating Jenkins with Other Technologies
      1. Jenkins and Docker – Linux guide
        1. Running Jenkins inside a Docker container – Linux
        2. Dynamic Jenkins slave nodes using Docker
          1. Pre-requisite requirements
          2. Implementation tutorial
      2. Integrating Jenkins with Ansible – Linux and Windows
      3. Jenkins and Artifactory
      4. Jenkins and Selenium Grid
        1. Spinning up a Selenium Grid
        2. Writing tests and integrating them into Jenkins
      5. Jenkins and Jira
      6. Summary
    18. 10. Extending Jenkins
      1. Setting up the development environment
      2. Creating a Jenkins plugin skeleton
      3. The plugin skeleton
      4. Importing a Maven-generated skeleton into IntelliJ
      5. The architecture of Jenkins plugins
        1. Understanding the Jenkins job lifecycle
        2. Using overrides
        3. Working with describables and descriptors
      6. Jelly tags and files
      7. Compiling and installing an HPI plugin
      8. Summary
    19. Index