Learning Continuous Integration with Jenkins - Second Edition - Nikhil Pathania - E-Book

Learning Continuous Integration with Jenkins - Second Edition E-Book

Nikhil Pathania

0,0
35,99 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

Speed up the software delivery process and software productivity using the latest features of Jenkins

About This Book

  • Take advantage of a Continuous Integration and Continuous Delivery solution to speed up productivity and achieve faster software delivery
  • See all the new features introduced in Jenkins 2.x, such as Pipeline as code, Multibranch pipeline, Docker Plugin, and more
  • Learn to implement Continuous Integration and Continuous Delivery by orchestrating multiple DevOps tools using Jenkins

Who This Book Is For

The book is for those with little or no previous experience with Agile or CI and CD. It's a good starting point for anyone new to this field who wants to leverage the benefits of CI and CD to increase productivity and reduce delivery time. It's ideal for Build and Release engineers, DevOps engineers, SCM (Software Configuration Management) engineers, developers, testers, and project managers. If you're already using Jenkins for CI, you can take your project to the next level—CD.

What You Will Learn

  • Get to know some of the most popular ways to set up Jenkins
  • See all the new features introduced in the latest Jenkins, such as pipeline as code, Multibranch pipeline, and more
  • Manage users, projects, and permissions in Jenkins to ensure better security
  • Leverage the power of plugins in Jenkins
  • Learn how to create a CI pipeline using Jenkins Blue Ocean
  • Create a distributed build farm using Docker and use it with Jenkins
  • Implement CI and CD using Jenkins
  • See the difference between CD and Continuous Deployment
  • Understand the concepts of CI

In Detail

In past few years, agile software development has seen tremendous growth. There is a huge demand for software delivery solutions that are fast yet flexible to numerous amendments. As a result, Continuous Integration (CI) and Continuous Delivery (CD) methodologies are gaining popularity.

This book starts off by explaining the concepts of CI and its significance in the Agile. Next, you'll learn how to configure and set up Jenkins in many different ways. The book exploits the concept of "pipeline as code" and various other features introduced in the Jenkins 2.x release to their full potential. We also talk in detail about the new Jenkins Blue Ocean interface and the features that help to quickly and easily create a CI pipeline. Then we dive into the various features offered by Jenkins one by one, exploiting them for CI and CD. Jenkins' core functionality and flexibility allows it to fit in a variety of environments and can help streamline the development process for all stakeholders. Next, you'll be introduced to CD and will learn how to achieve it using Jenkins.

Through this book's wealth of best practices and real-world tips, you'll discover how easy it is to implement CI and CD using Jenkins.

Style and approach

The book uses a simple Maven project to demonstrate the implementation of CI and CD using Jenkins. This step-by-step guide shows you how to implement CI/CD and can be used as a template to perform CI/CD in your projects.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 280

Veröffentlichungsjahr: 2017

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Learning Continuous Integration with Jenkins

Second Edition

 

 

 

 

 

 

 

A beginner's guide to implementing Continuous Integration and Continuous Delivery using Jenkins 2

 

 

 

 

 

 

 

 

 

 

Nikhil Pathania

 

 

 

 

BIRMINGHAM - MUMBAI

Learning Continuous Integration with Jenkins

Second Edition

Copyright © 2017 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: May 2016

Second edition: December 2017

 

Production reference: 1191217

Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.

ISBN 978-1-78847-935-6

 

www.packtpub.com

Credits

Author

Nikhil Pathania

Copy Editor

Safis Editing

Reviewer

Deep Mehta

Project Coordinator

Virginia Dias

Commissioning Editor

Vijin Boricha

Proofreader

Safis Editing

Acquisition Editor

Prateek Bharadwaj

Indexer

Rekha Nair

Content Development Editor

Sharon Raj

Graphics

Kirk D'Penha

Tania Dutta

Technical Editor

Khushbu Sutar

Production Coordinator

Melwyn Dsa

 

About the Author

Nikhil Pathania is currently practicing DevOps at Siemens Gamesa Renewable Energy. He started his career as an SCM engineer and later moved on to learn various tools and technologies in the fields of automation and DevOps. Throughout his career, Nikhil has promoted and implemented Continuous Integration and Continuous Delivery solutions across diverse IT projects. He enjoys finding new and better ways to automate and improve manual processes and help teams know more about their project's SDLC by bringing valuable metrics. He is also actively working on utilizing Elastic Stack and container technologies efficiently for DevOps.

In his spare time, Nikhil likes to read, write, and meditate. He is an avid climber and also hikes and cycles.

You can reach Nikhil on twitter at @otrekpiko.

First and foremost, my beautiful wife, Karishma, without whose love and support this book would not have been possible. Great thanks to Deep Mehta who provided me with valuable feedback throughout the writing process.  Special thanks to the following people who worked hard to make this book the best possible experience for the readers: Sharon Raj, Khushbu Sutar, and the whole Packt Publishing technical team working in the backend. And finally, great thanks to the Jenkins community for creating such fantastic software.

About the Reviewer

Deep Mehta is a DevOps engineer who works in CI/CD automation. He is currently working in the San Francisco Bay Area. He helps clients design resilient infrastructure, identifying top microservices patterns and self-healing infrastructure automation. His area of interest is large-scale distributed computing, data science, cloud, and system administration.

I acknowledge my mom, papa, and sister for supporting me to produce this book.

www.PacktPub.com

For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files 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 [email protected] 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.

https://www.packtpub.com/mapt

Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.

Why subscribe?

Fully searchable across every book published by Packt

Copy and paste, print, and bookmark content

On demand and accessible via a web browser

Customer Feedback

Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial process. To help us improve, please leave us an honest review on this book's Amazon page at https://www.amazon.com/dp/1788479351.

If you'd like to join our team of regular reviewers, you can email us at [email protected]. We award our regular reviewers with free eBooks and videos in exchange for their valuable feedback. Help us be relentless in improving our products!

Table of Contents

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Reader feedback

Customer support

Downloading the example code

Downloading the color images of this book

Errata

Piracy

Questions

Concepts of Continuous Integration

Software Development Life Cycle

Requirement analysis

Design

Implementation

Testing

Evolution

Waterfall model of software development

Disadvantages of the Waterfall model

Advantages of the Waterfall model

Agile to the rescue

The twelve agile principles

How does the Agile software development process work?

Advantages of Agile software development process

The Scrum framework

Important terms used in the Scrum framework

How does Scrum work?

Sprint Planning

Sprint cycle

Daily Scrum meeting

Monitoring Sprint progress

Sprint Review

Sprint Retrospective

Continuous Integration

Agile runs on CI

Types of projects that benefit from CI

Elements of CI

Version control system

Branching strategy

GitFlow branching model

CI tool

Self-triggered builds

Code coverage

Code coverage tools

Static code analysis

Automated testing

Binary repository tools

Automated packaging

Benefits of using CI

Freedom from long integrations

Metrics

Catching issues faster

Rapid development

Spend more time adding features

Summary

Installing Jenkins

Running Jenkins inside a servlet container

Prerequisites

Installing Java

Installing Apache Tomcat

Enabling the firewall and port 8080

Configuring the Apache Tomcat server

Installing Jenkins on the Apache Tomcat server

Installing Jenkins alone on an Apache Tomcat server

Setting up the Jenkins home path

Installing a standalone Jenkins server on Windows

Prerequisites

Installing Java

Installing the latest stable version of Jenkins

Starting, stopping, and restarting Jenkins on Windows

Installing a standalone Jenkins server on Ubuntu

Prerequisites

Installing Java

Installing the latest version of Jenkins

Installing the latest stable version of Jenkins

Starting, stopping, and restarting Jenkins on Ubuntu

Installing a standalone Jenkins server on Red Hat Linux

Prerequisites

Installing Java

Installing the latest version of Jenkins

Installing the latest stable version of Jenkins

Starting, stopping, and restarting Jenkins on Red Hat Linux

Running Jenkins behind a reverse proxy

Prerequisites

Installing and configuring Nginx

Configuring the firewall on a Nginx server

Starting, stopping, and restarting the Nginx server

Securing Nginx using OpenSSL

Creating an SSL certificate

Creating strong encryption settings

Modifying the Nginx configuration

Enabling the changes and testing our Nginx setup

Configuring the Jenkins server

Adding reverse proxy settings to the Nginx configuration

Running Nginx and Jenkins on the same machine

Running Jenkins on Docker

Prerequisites

Setting up a Docker host

Setting up the repository

Installing Docker

Installing from a package

Running the Jenkins container

Running a Jenkins container using a data volume

Testing the data volume

Creating development and staging instances of Jenkins

Prerequisites

Creating an empty data volume

Copying data between data volumes

Creating the development and staging instances

Summary

The New Jenkins

The Jenkins setup wizard

Prerequisites

Unlocking Jenkins

Customizing Jenkins

Creating the first admin user

The new Jenkins pipeline job

Prerequisite

Creating a Jenkins pipeline job

The Global Tool Configuration page

Jenkins pipeline Stage View

Declarative Pipeline syntax

Basic structure of a Declarative Pipeline

The node block

The stage block

Directives

Steps

Jenkins pipeline syntax utility

Prerequisite

Installing the Pipeline Maven Integration Plugin

Creating a Jenkins pipeline using the pipeline syntax utility

Multibranch pipeline

Prerequisite

Adding GitHub credentials inside Jenkins

Configuring Webhooks on GitHub from Jenkins

Create a new repository on GitHub

Using a Jenkinsfile

Creating a Multibranch pipeline in Jenkins

Re-register the Webhooks

Jenkins Multibranch pipeline in action

Creating a new feature branch to test the multibranch pipeline

Jenkins Blue Ocean

Installing the Jenkins Blue Ocean plugin

View your regular Jenkins pipeline in Blue Ocean

Creating a pipeline in Blue Ocean

Summary

Configuring Jenkins

The Jenkins Plugin Manager

Updating Jenkins plugins

Installing a new Jenkins plugin

Uninstalling or downgrading a Jenkins plugin

Configuring proxy settings in Jenkins

Manually installing a Jenkins plugin

Jenkins backup and restore

Installing the Periodic Backup plugin

Configuring the Periodic Backup plugin

Creating a Jenkins backup

Restoring a Jenkins backup

Viewing the backup and restore logs

Upgrading Jenkins

Upgrading Jenkins running on Tomcat Server

Upgrading standalone Jenkins running on Windows

Upgrading standalone Jenkins running on Ubuntu

Upgrading Jenkins running on a Docker container

User administration

Enabling/disabling global security on Jenkins

Enabling/disabling computers to remember user credentials

Authentication methods

Delegating to a servlet container

Jenkins' own user database

LDAP

Unix user/group database

Creating new users inside Jenkins

People page

User information and settings in Jenkins

Authorization methods

Anyone can do anything

Legacy mode

Logged-in users can do anything

Matrix-based security

Project-based Matrix Authorization Strategy

Summary

Distributed Builds

Distributed build and test

The Jenkins Manage Nodes page

Adding Jenkins slaves – standalone Linux machine/VMs

Passing environment variables to Jenkins slaves

Passing tools' locations to Jenkins slaves

Launching a Jenkins slave via SSH

More about the active Jenkins slave

Adding Jenkins slaves – standalone Windows machine/VMs

Launching a Jenkins slave via Java Web Start

Adding Jenkins slaves – Docker containers

Prerequisites

Setting up a Docker server

Setting up the repository

Installing Docker using apt-get

Installing Docker using a .deb package

Enabling Docker remote API

Modifying the docker.conf file

Modifying the docker.service file

Installing the Docker plugin

Configuring the Docker plugin

Creating a Docker image – Jenkins slave

Adding Docker container credentials in Jenkins

Updating the Docker settings inside Jenkins

Summary

Installing SonarQube and Artifactory

Installing and configuring SonarQube

Installing Java

Downloading the SonarQube package

Running the SonarQube application

Resetting the default credentials and generating a token

Creating a project inside SonarQube

Installing the build breaker plugin for SonarQube

Creating quality gates

Updating the default quality profile

Installing the SonarQube plugin in Jenkins

Configuring the SonarQube plugin in Jenkins

Installing and configuring Artifactory

Installing Java

Downloading the Artifactory package

Running the Artifactory application

Resetting the default credentials and generating an API key

Creating a repository in Artifactory

Adding Artifactory credentials inside Jenkins

Installing the Artifactory plugin in Jenkins

Configuring the Artifactory Plugin

Summary

Continuous Integration Using Jenkins

Jenkins CI design  

Branching strategy

The master branch

The integration branch

The feature branch

The CI pipeline

Toolset for CI

Creating the CI pipeline

Creating a new repository on GitHub

Using the SonarQube scanner for Maven

Writing the Jenkinsfile for CI

Spawning a Docker container – build agent

Downloading the latest source code from VCS

Pipeline code to perform the build and unit test

Pipeline code to perform static code analysis

Pipeline code to perform integration testing

Pipeline code to publish built artifacts to Artifactory

Combined CI pipeline code

Using a Jenkinsfile

Creating a Multibranch Pipeline in Jenkins

Re-registering the Webhooks

Continuous Integration in action

Viewing static code analysis in SonarQube

Accessing SonarQube analysis right from Jenkins

Viewing artifacts in Artifactory

Failing the build when quality gate criteria are not met

Summary

Continuous Delivery Using Jenkins

Jenkins CD design

Branching strategy

The release branch

CD pipeline

Toolset for CD

Creating a Docker image – performance testing

Adding Docker container credentials in Jenkins

Updating the Docker settings inside Jenkins

Creating a performance test using JMeter

Installing Java

Installing Apache JMeter

Starting JMeter

Creating a performance test case

Creating a thread group

Creating a sampler

Adding a listener

The CD pipeline

Writing the Jenkinsfile for CD

Revisiting the pipeline code for CI

Pipeline code to stash the build artifacts

Spawning a Docker container – performance testing

Pipeline code to start Apache Tomcat

Pipeline code to deploy build artifacts

Pipeline code to run performance testing

Pipeline code to promote build artifacts in Artifactory

Combined CD pipeline code

CD in action

Summary

Continuous Deployment Using Jenkins

What is Continuous Deployment?

How Continuous Deployment is different from Continuous Delivery

Who needs Continuous Deployment?

Creating a production server

Installing Vagrant

Installing VirtualBox

Creating a VM using Vagrant

Creating a Vagrantfile

Spawning a VM using Vagrant

Adding production server credentials inside Jenkins

Installing a Jenkins slave on a production server

Creating a Jenkins Continuous Deployment pipeline

A revisit to the pipeline code for CD

Pipeline code for a production Jenkins slave

Pipeline code to download binaries from Artifactory

Combined Continuous Deployment pipeline code

Update the Jenkinsfile

Continuous Delivery in action

Summary

Supporting Tools and Installation Guide

Exposing your localhost server to the internet

Installing Git on Windows/Linux 

Installing Git on Windows

Installing Git on Linux

Preface

In the past few years, the agile model of software development has seen a considerable amount of growth around the world. There is massive demand for a software delivery solution that is fast and flexible to frequent amendments, especially in the e-commerce sector. As a result, the Continuous Integration and Continuous Delivery methodologies are gaining popularity.

Whether small or big, all types of project gain benefits, such as early issue detection, avoiding lousy code into production, and faster delivery, which leads to an increase in productivity.

This book, Learning Continuous Integration with Jenkins Second Edition, serves as a step-by-step guide to setting up a Continuous Integration, Continuous Delivery, and Continuous Deployment system using hands-on examples. The book is 20% theory and 80% practical. It starts by explaining the concept of Continuous Integration and its significance in the Agile world, with a complete chapter dedicated to this. Users then learn to configure and set up Jenkins, followed by implementing Continuous Integration and Continuous Delivery using Jenkins. There is also a small chapter on Continuous Deployment, which talks primarily about the difference between Continuous Delivery and Continuous Deployment.

 

What this book covers

Chapter 1, Concepts of Continuous Integration, gives an account of how some of the most popular and widely used software development methodologies gave rise to Continuous Integration. This is followed by a detailed explanation of the various requirements and best practices to achieve Continuous Integration.

Chapter 2, Installing Jenkins, is a step-by-step guide all about installing Jenkins across various platforms, including Docker.

Chapter 3, The New Jenkins, provides an overview of how the new Jenkins 2.x looks and feels, with an in-depth explanation of its essential constituents. It also introduces readers to the new features added in Jenkins 2.x.

Chapter 4, Configuring Jenkins, focuses on accomplishing some basic Jenkins administration tasks.

Chapter 5, Distributed Builds, explores how to implement a build farm using Docker. It also talks about adding standalone machines as Jenkins slaves.

Chapter 6, Installing SonarQube and Artifactory, covers installing and configuring SonarQube and Artifactory for CI.

Chapter 7, Continuous Integration Using Jenkins, takes you through a Continuous Integration design and the means to achieve it using Jenkins, in collaboration with some other DevOps tools.

Chapter 8, Continuous Delivery Using Jenkins, outlines a Continuous Delivery design and the means to achieve it using Jenkins, in collaboration with some other DevOps tools.

Chapter 9, Continuous Deployment Using Jenkins, explains the difference between Continuous Delivery and Continuous Deployment. It also features a step-by-step guide to implementing Continuous Deployment using Jenkins.

Appendix, Supporting Tools and Installation Guide, takes you through the steps required to make your Jenkins server accessible over the internet and the installation guide for Git.

What you need for this book

To be able to follow everything described in the book, you will need a machine with the following configurations:

Operating systems

:

Windows 7/8/10

Ubuntu 14 and later

Hardware requirements

:

A machine with a minimum 4 GB memory and a multicore processor

Other requirements

:

A GitHub account (public or private)

Who this book is for

This book is aimed at readers with little or no previous experience with Agile or Continuous Integration and Continuous Delivery. It serves as a great starting point for anyone who is new to this field and would like to leverage the benefits of Continuous Integration and Continuous Delivery to increase productivity and reduce delivery time.

Build and release engineers, DevOps engineers, (Software Configuration Management) SCM engineers, developers, testers, and project managers can all benefit from this book.

Readers who are already using Jenkins for Continuous Integration can learn to take their project to the next level, which is Continuous Delivery.

The current edition of the book is a complete reboot of its predecessor. Readers of the first edition can take advantage of some of the new stuff discussed in the current edition, such as Pipeline as Code, Multibranch Pipelines, Jenkins Blue Ocean, distributed build farms using Docker, and more.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning. Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "This will download a .hpi file on your system."

A block of code is set as follows:

stage ('Performance Testing'){ sh '''cd /opt/jmeter/bin/ ./jmeter.sh -n -t $WORKSPACE/src/pt/Hello_World_Test_Plan.jmx -l $WORKSPACE/test_report.jtl'''; step([$class: 'ArtifactArchiver', artifacts: '**/*.jtl'])}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

stage ('Performance Testing'){

sh '''cd /opt/jmeter/bin/ ./jmeter.sh -n -t $WORKSPACE/src/pt/Hello_World_Test_Plan.jmx -l $WORKSPACE/test_report.jtl'''; step([$class: 'ArtifactArchiver', artifacts: '**/*.jtl'])}

The extra "\" used in some of the commands is used to only indicate that the command continues in the next line. Any command-line input or output is written as follows:

cd /tmp wget https://archive.apache.org/dist/tomcat/tomcat-8/ \ v8.5.16/bin/apache-tomcat-8.5.16.tar.gz

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "From the Jenkins dashboard, click on the Manage Jenkins | Plugin Manager | Available tab."

Warnings or important notes appear like this.
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 disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply email [email protected], and mention the book's title in 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 at 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 this book 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 emailed directly to you. You can download the code files by following these steps:

Log in or register to our website using your email address and password.

Hover the mouse pointer on the

SUPPORT

tab at the top.

Click on

Code Downloads & Errata

.

Enter the name of the book in the

Search

box.

Select the book for which you're looking to download the code files.

Choose from the drop-down menu where you purchased this book from.

Click on

Code Download

.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR / 7-Zip for Windows

Zipeg / iZip / UnRarX for Mac

7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Learning-Continuous-Integration-with-Jenkins-Second-Edition. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/LearningContinuousIntegrationwithJenkinsSecondEdition_ColorImages.pdf.

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 could 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 to our website or added to any list of existing errata under the Errata section of that title. To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted 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 [email protected] with a link to the suspected pirated material. We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.

Concepts of Continuous Integration

We will begin this chapter with an overview of the two primary software development methodologies of the era: Waterfall, and agile. An understanding of their concepts and implications will help us answer how Continuous Integration (CI) came into existence.

Next, we will try to understand the concept behind CI and the elements that make it. Reading through the topics, you will see how CI helps projects go agile. After completing this chapter, you should be able to:

Describe how CI came into existence.

Define what CI is.

Describe the elements of CI.

Software Development Life Cycle

For those of you who are not familiar with the term: Software Development Life Cycle, let us try to understand it.

The Software Development Life Cycle, also sometimes referred to as SDLC for short, is the process of planning, developing, testing, and deploying software.

Teams follow a sequence of phases, and each phase uses the outcome of its previous phase, as shown in the following diagram:

Software Development Life Cycle

Let's take a look at the SDLC phases in detail.

Requirement analysis

This is the first stage of the cycle. Here, the business team (mostly comprised of business analysts) perform a requirement analysis of their project's business needs. The requirements can be internal to the organization, or external, from a customer. This study involves finding the nature and scope of the requirements. With the gathered information, there is a proposal to either improve the system or create a new one. The project cost gets decided, and benefits are laid out. Then the project goals are defined.

Design

The second phase is the design phase. Here, the system architects and the system designers formulate the desired features of the software solution and create a project plan. This plan may include process diagrams, overall interface, and layout design, along with a vast set of documentation.

Implementation

The third phase is the implementation phase. Here, the project manager creates and assigns work to the developers. The developers develop the code depending on the tasks and goals defined in the design phase. This phase may last from a few months to a year, depending on the project.

Testing

The fourth phase is the testing phase. When all the decided features are developed, the testing team takes over. For the next few months, all features are thoroughly tested. Every module of the software is collected and tested. Defects are raised if any bugs or errors occur while testing. In the event of a failure, the development team quickly acts to resolve the failures. The thoroughly tested code is then deployed into the production environment.

Evolution

The last phase is the evolution phase or the maintenance phase. Feedback from the users/customers is analyzed, and the whole cycle of developing, testing, and releasing the new features and fixes in the form of patches or upgrades repeats.

Waterfall model of software development

One of the most famous and widely used software development processes is the Waterfall model. The Waterfall model is a sequential software development process. It was derived from the manufacturing industry. One can see a highly structured flow of processes that run in one direction. At the time of its creation, there were no other software development methodologies, and the only thing the developers could have imagined was the production line process that was simple to adapt for software development.

The following diagram illustrates the Waterfall model of software development:

Waterfall model

The Waterfall approach is simple to understand, as the steps involved are similar to that of the SDLC.

First, there is a requirement analysis phase, which is followed by the designing phase. There is a considerable time spent on the analysis and the designing part. And once it's over, there are no further additions or deletions. In short, once the development begins, there is no modification allowed in the design.

Then comes the implementation phase, where the actual development takes place. The development cycle can range from three months to six months. During this time, the testing team is usually free. When the development cycle is completed, a whole week's time is planned for performing the integration of the source code. During this time, many integration issues pop up and are fixed immediately. This stage is followed by the testing phase.

When the testing starts, it goes on for another three months or more, depending on the software solution. After the testing completes successfully, the source code is then deployed in the production environment. For this, a day or so is again planned to carry out the deployment in production. There is a possibility that some deployment issues may pop up. When the software solution goes live, teams get feedback and may also anticipate issues.

The last phase is the maintenance phase. Feedback from the users/customers is analyzed, and the whole cycle of developing, testing, and releasing new features and fixes in the form of patches or upgrades repeats.

There is no doubt that the Waterfall model worked remarkably for decades. However, flaws did exist, but they were simply ignored for a long time. Since, way back then software projects had ample time and resources to get the job done.

However, looking at the way software technologies have changed over the past few years, we can easily say that the Waterfall model won't suit the requirements of the current world.

Disadvantages of the Waterfall model

The following are some of the disadvantages of the Waterfall model:

Working software is produced only at the end of the SDLC, which lasts for a year or so in most cases.

There is a huge amount of uncertainty.

It is not suitable for projects where the demand for new features is too frequent. For example, e-commerce projects.

Integration is performed only after the entire development phase is complete. As a result, integration issues are found at a much later stage and in large quantities.

There is no backward traceability.

It's difficult to measure progress within stages.

Advantages of the Waterfall model

By looking at the disadvantages of the Waterfall model, we can say that it's mostly suitable for projects where:

The requirements are well documented and fixed.

There is enough funding available to maintain a management team, a testing team, a development team, a build and release team, a deployment team, and so on.

The technology is fixed, and not dynamic.

There are no ambiguous requirements. And most importantly, they don't pop up during any other phase apart from the requirement analysis phase.

Agile to the rescue

The name Agile rightly suggests quick and easy. Agile is a collection of methods where software is developed through collaboration among self-organized teams. The principles behind agile are incremental, quick, flexible software development, and it promotes adaptive planning.

The Agile software development process is an alternative to the traditional software development processes discussed earlier.

The twelve agile principles

The following are the twelve principles of the agile model:

Customer satisfaction through early and continuous delivery of useful software.

Welcome changing requirements, even late in development.

Working software is frequently delivered (in weeks, rather than months).

Close daily cooperation between businesses, people, and developers.

Projects are built around motivated individuals, who should be trusted.

Face-to-face conversation is the best form of communication (co-location).

Working software is the principal measure of progress.

Sustainable development—able to maintain a constant pace.

Continuous attention to technical excellence and good design.

Simplicity—the art of maximizing the amount of work not done—is essential.

Self-organizing teams.

Regular adaptation to changing circumstances.

To know more about the Agile principles visit the link: http://www.agilemanifesto.org.

The twelve principles of Agile software development indicate the expectations of the current software industry and its advantages over the Waterfall model.

How does the Agile software development process work?

In the Agile software development process, the whole software application is split into multiple features or modules. These features are delivered in iterations. Each iteration lasts for three weeks, and involves cross-functional teams that work simultaneously in various areas, such as planning, requirement analysis, designing, coding, unit testing, and acceptance testing.

As a result, no person sits idle at any given point in time. This is quite different from the Waterfall model wherein while the development team is busy developing the software, the testing team, the production team, and everyone else is idle or underutilized. The following diagram illustrates the Agile model of software development:

Agile methodology

From the preceding diagram, we can see that there is no time spent on requirement analysis or design. Instead, a very high-level plan is prepared, just enough to outline the scope of the project.

The team then goes through a series of iterations. Iteration can be classified as time frames, each lasting for a month or even a week in some mature projects. In this duration, a project team develops and tests features. The goal is to develop, test, and release a feature in a single iteration. At the end of the iteration, the feature goes for a demo. If the clients like it, then the feature goes live. But, if it gets rejected, the feature is taken as a backlog, re-prioritized, and again worked upon in the consecutive iteration.