Book Image

Mastering Jenkins

By : jmcallister -, Jonathan McAllister
Book Image

Mastering Jenkins

By: jmcallister -, Jonathan McAllister

Overview of this book

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.
Table of Contents (18 chapters)
Mastering Jenkins
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Jenkins is a highly acclaimed award-winning build and automation orchestration solution. It represents the cumulative efforts of hundreds of open-source developers, quality assurance engineers, and DevOps personnel worldwide. What makes this solution uniquely innovative is it is continuously updated, improved upon, and supported by this cohesively vibrant open-source community. It is through this open-source development effort that Jenkins has remained in the forefront of Continuous Integration, and Continuous Delivery practices.

The Jenkins platform bridges engineering disciplines, quality assurance landscapes, and business interests in an effort to connect traditionally isolated factions and transform them into cohesive engineering teams. Over the years it has vaulted in popularity and gained notoriety as an industry standard tool. Through its extensibility and collaboration initiatives its adoption rate has grown exponentially and now touts well over 100K installations worldwide.

I was formally introduced to Jenkins in 2008 when it was still Hudson. It was during this era that Hudson was just beginning to gain momentum by engineering groups outside of the Java development community. The software configuration management team I worked for was looking to implement a standardized architecture and delivery service solution across a large number of diversely acquired technology stacks. This began our quest to solidify a set of standards in build and delivery that could be applied across these diverse technology stacks and scale.

These experiences provided me with a pretty solid understanding of continuous integration, continuous delivery, build pipelines, automated testing, and the capabilities of Jenkins. By 2012 we were able to scale our implementations across a multitude of technology stacks of varying size and scope. All of these experiences would eventually culminate in me writing this book.

What this book covers

This book represents the amalgamation of a decade's worth of professional research, development, and automation engineering at numerous organizations with diverse technology disciplines. I wrote this book in an effort to provide a practical implementation guide for continuous integration, continuous delivery, and continuous deployment. With this book, my objective was to provide readers with some of the tools they will need while architecting, evangelizing, and implementing complete end-to-end build pipeline solutions at organizations of varying sizes and engineering topologies.

Chapter 1, Setup and Configuration of Jenkins, aims to teach reader how to manage instances of Jenkins of any size or scale. This is not an easy feat because Jenkins is highly diverse and supports almost any platform. You will learn about the initial setup, backup strategies, configuration techniques, best practices, and how to horizontally scale and properly manage the service.

Chapter 2, Distributed Builds – Master/Slave Mode, provides you with a complete guide on how to set up distributed build solutions and slave agents. This is a critical implementation and helps you understand when Jenkins needs to expand and support larger audiences and more diverse technology stacks.

In Chapter 3, Creating Views and Jobs in Jenkins, and Chapter 4, Managing Views and Jobs in Jenkins, we aim at documenting the knobs and dials that Jenkins provides on the dashboard, and the contained views and jobs. This is fundamental Jenkins knowledge and the goal here is to provide a solid understanding of the Jenkins platform.

Chapter 5, Advanced Automated Testing, talks about how to improve quality assurance efficiency. It teaches you how to architect and implement automated testing solutions that provide business value. This is crucial to any continuous solution because the pipeline must remain efficient and free of bottlenecks. Implementing automated testing is always a gentle balancing act. There is a trade-off between the time spent executing test automation and ensuring the rapid velocity of delivery.

Automated deployments are a cornerstone of continuous practices and build pipelines. Chapter 6, Software Deployments and Delivery, discusses how to implement scalable automated deployment jobs in Jenkins. This includes upstream and downstream jobs and how to manage them through naming conventions. In this chapter, we will discover some tips and tricks aimed at helping to keep deployments nimble and releases efficient.

Chapter 7, Build Pipelines, introduces the concept of a build pipeline and teaches you how to develop and scale them. Build pipelines are a foundational requirement of continuous delivery and continuous deployment. This chapter has been written in an effort to provide you with a set of scalable practices that can be applied across a multitude of technology stacks.

Chapter 8, Continuous Practices, defines continuous integration, continuous delivery, and continuous deployment. It provides a practice implementation guide for each. Jenkins has evolved and extended dramatically and now supports a complete array of continuous practices. This chapter aims to convey a set of defined implementation approaches to continuous integration, continuous delivery, and continuous deployment with examples for each. Jenkins integrates extraordinarily well with hundreds of diverse technologies.

Chapter 9, Integrating Jenkins with Other Technologies, introduces some of the more exciting automation technologies, such as Docker, Ansible, Selenium, Artifactory, and Jira. This chapter shows you how to interconnect them through Jenkins. The ability to extend Jenkins through its plugin architecture is one of the primary reasons that it has become so popular.

Chapter 10, Extending Jenkins, aims at writing a set of basic how-to articles. It describes how to begin to write plugins, how to extend Jenkins with extension points, and how to manipulate the Jenkins system even further.

I hope you will embark on a journey with me in discovering Jenkins, mastering the concepts that surround build pipelines and implementing automation at scale. Writing a book is something I have dreamed of doing for many years. I hope that you will gain as much in reading the book as I have gained by writing it.

What you need for this book

An existing installation of Jenkins is recommended (but not needed). Beyond that, we have provided examples in the following programming languages:

  • Ruby v1.93

  • Java

  • C# (via MSBuild)

  • JavaScript

  • Bash/Dash + Expect

  • Ansible YAML

Who this book is for

This book is intended for novice and intermediate-level Jenkins enthusiasts who are in a unique position to implement and evangelize continuous integration practices, continuous delivery solutions, and as a result build pipelines.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "For example if the Jenkins system is configured to utilize a context path of http://localhost:8080/jenkins"

A block of code is set as follows:

<arguments>-Xrs –Xmx512m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080</arguments>

Any command-line input or output is written as follows:

$Jenkins-Mirror>sudo su – root
$Jenkins-Mirror>cat /tmp/id_rsa.pub >> ~/.ssh/authorized_keys

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Click on the Recovery tab as shown"

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

The Website

When this book, I decided it would be valuable to set up a website dedicated to supporting its readers. Please feel free to visit and drop me a line with any comments or questions. The URL is provided below:

http://www.masteringjenkins.com/

Questions

You can contact us on our Mastering Jenkins website at or you can submit questions to the publisher at if you are having a problem with any aspect of the book, and we will do our best to address it.