Continuous Integration, Delivery, and Deployment

Book description

Getting started with the processes and the tools to continuously deliver high-quality software

About This Book

  • Incorporate popular development practices to prevent messy code
  • Automate your build, integration, release, and deployment processes with Jenkins, Git, and Gulp - and learn how continuous integration (CI) can save you time and money
  • Gain an end-to-end overview of Continuous Integration using different languages (JavaScript and C#) and tools (Gulp and Jenkins)

Who This Book Is For

This book is for developers who want to understand and implement Continuous Integration and Delivery in their daily work. A basic knowledge of at least JavaScript and HTML/CSS is required. Knowing C# and SQL will come in handy. Most programmers who have programmed in a (compiled) C-like language will be able to follow along.

What You Will Learn

  • Get to know all the aspects of Continuous Integration, Deployment, and Delivery
  • Find out how Git can be used in a CI environment
  • Set up browser tests using Karma and Selenium and unit tests using Jasmine
  • Use Node.js, npm, and Gulp to automate tasks such as linting, testing, and minification
  • Explore different Jenkins jobs to integrate with Node.js and C# projects
  • Perform Continuous Delivery and Deployment using Jenkins
  • Test and deliver a web API

In Detail

The challenge faced by many teams while implementing Continuous Deployment is that it requires the use of many tools and processes that all work together. Learning and implementing all these tools (correctly) takes a lot of time and effort, leading people to wonder whether it's really worth it. This book sets up a project to show you the different steps, processes, and tools in Continuous Deployment and the actual problems they solve.

We start by introducing Continuous Integration (CI), deployment, and delivery as well as providing an overview of the tools used in CI. You'll then create a web app and see how Git can be used in a CI environment. Moving on, you'll explore unit testing using Jasmine and browser testing using Karma and Selenium for your app. You'll also find out how to automate tasks using Gulp and Jenkins. Next, you'll get acquainted with database integration for different platforms, such as MongoDB and PostgreSQL. Finally, you'll set up different Jenkins jobs to integrate with Node.js and C# projects, and Jenkins pipelines to make branching easier.

By the end of the book, you'll have implemented Continuous Delivery and deployment from scratch.

Style and approach

This practical book takes a step-by-step approach to explaining all the concepts of Continuous Integration and delivery, and how it can help you deliver a high-quality product.

Table of contents

  1. 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. Downloading the color images of this book
      3. Errata
      4. Piracy
      5. Questions
  2. Continuous Integration, Delivery, and Deployment Foundations
    1. Continuous Integration
      1. Source control
      2. CI server
      3. Software quality
        1. Unit tests
        2. Integration tests
          1. Big bang testing
          2. Incremental testing
        3. Acceptance tests
        4. Smoke tests
        5. Other quality gates
      4. Automation
      5. Teamwork
    2. Continuous Delivery
    3. Continuous Deployment
    4. Summary
  3. Setting Up a CI Environment
    1. Installing a Virtual Machine
      1. Installing Ubuntu
    2. Installing Git
      1. Installing GitLab
        1. Configuring GitLab
      2. Using Git
    3. Installing Jenkins
      1. Installing Jenkins on Ubuntu
      2. Installing Jenkins on Windows
      3. Configuring Jenkins
    4. Installing PostgreSQL
      1. Installing PostgreSQL on Ubuntu
      2. Installing PostgreSQL on Windows
      3. Installing pgAdmin
    5. Installing SonarQube
      1. Configuring PostgreSQL
      2. Installing SonarQube on Ubuntu
      3. Installing SonarQube on Windows
      4. Trigger SonarQube from Jenkins
    6. Summary
  4. Version Control with Git
    1. The basics
      1. Centralized Source Control Management
      2. Distributed Source Control Management
      3. The working directory
      4. The staging area
      5. Committing and pushing
      6. Reviewing commits
      7. Pulling and stashing
    2. Branching
      1. Merging
      2. Cherry picking
      3. Rebasing
    3. Reverting changes
    4. The branching model
      1. Tagging
    5. Summary
  5. Creating a Simple JavaScript App
    1. The web shop specs
    2. Installing Node.js and npm
    3. Creating the project
    4. Creating the Home page
    5. Creating the Product page
    6. Creating the Search page
    7. Creating the Shopping cart page
    8. Summary
  6. Testing Your JavaScript
    1. Unit testing with Jasmine
      1. The Yeoman shortcut
      2. Why Jasmine?
    2. Testing the web shop
    3. Running tests with Karma
      1. Installation
      2. Karma plugins
        1. Browser launchers
        2. Code coverage
        3. JUnit reporter
      3. Running Mocha and Chai with Karma
    4. End-To-End testing with Selenium
      1. Running Selenium tests with Protractor
        1. Testing our website
        2. Customizing reporters
        3. Testing with Mocha
    5. Headless browser testing
      1. PhantomJS
    6. Summary
  7. Automation with Gulp
    1. Gulp basics
      1. The Gulp API
    2. Gulp plugins
      1. Minification
      2. Cleaning your build
      3. Checking file sizes
      4. Linting with JSHint
    3. Running your Karma tests
    4. Getting our site production ready
      1. Minifying HTML
      2. Minifying CSS
      3. Bundling JavaScript with Browserify
        1. Karma and Browserify
      4. Concatenating CSS
      5. Replacing HTML references
    5. Putting it all together
    6. Summary
  8. Automation with Jenkins
    1. Installing Node.js and npm
    2. Creating a Jenkins project
    3. Executing Gulp in Jenkins
    4. Publishing test results
      1. JUnit report
      2. Cobertura report
      3. HTML report
    5. Build triggers
      1. Build periodically
      2. Poll SCM
      3. On commit
    6. Setting up email notifications
    7. Setting up SonarQube
      1. Setting up email
      2. HTML and CSS analysis
      3. Including code coverage
      4. Leak periods
    8. Artifacts
    9. Running on Windows with Jenkins Slaves
      1. Running our tests
      2. Triggering a project pipeline
    10. Summary
  9. A NodeJS and MongoDB Web App
    1. Installing MongoDB
      1. Installing MongoDB on Ubuntu
      2. Installing MongoDB on Windows
    2. Creating the Node.js Back-end
      1. Express
      2. EJS
    3. The Login Page
      1. Connecting with AJAX
    4. Saving to MongoDB
      1. Moving our Products to MongoDB
      2. Putting the Shopping Cart in MongoDB
    5. Moving the Shopping Cart Module
    6. Gulp
    7. Jenkins
      1. PM2
    8. Summary
  10. A C# .NET Core and PostgreSQL Web App
    1. Installing .NET Core and Visual Studio Code
    2. Creating the views
    3. Running tasks
    4. Adding the database
      1. Entity Framework Core
      2. Selecting the data
    5. Fixing the login
      1. Adding to the cart
    6. Testing the database
      1. Installing pgTap
    7. Testing our C# code
      1. Reporting
    8. Adding Selenium tests
    9. Jenkins
      1. Building the project
      2. Testing the project
      3. Testing the database
    10. Summary
  11. Additional Jenkins Plugins
    1. Views
    2. Cleanup workspaces
    3. Conditional build steps
    4. Pipelines
    5. Promoted builds
    6. Parameterized builds
    7. Triggering builds remotely
    8. Blue ocean
    9. Security
      1. Jenkins on HTTPS
        1. HTTPS on Linux
        2. HTTPS on Windows
      2. Jenkins security
        1. Role-based authorization strategy
    10. Summary
  12. Jenkins Pipelines
    1. Groovy
    2. Pipeline projects
      1. Declarative pipeline syntax
      2. Scripted pipeline syntax
      3. Pipeline stages
      4. The snippet generator
      5. Building the web shop
    3. The Jenkinsfile
    4. Multibranch pipeline
      1. Branch scripts
    5. Completing the script
      1. Node.js tests
      2. SonarQube
      3. Selenium tests
      4. Archiving artifacts
      5. Build failure
    6. Summary
  13. Testing a Web API
    1. Building a REST service
    2. Postman
      1. Writing tests
      2. Testing XML
      3. Collections
      4. Environments
    3. Newman
    4. Summary
  14. Continuous Delivery
    1. Branching
    2. Manual deployment
      1. Installing NGINX
      2. Node.js web shop
        1. PM2
        2. MongoDB
        3. Run
        4. E2E testing
      3. C# .NET Core web shop
        1. Run
        2. PostgreSQL
    3. Summary
  15. Continuous Deployment
    1. JavaScript Deployment using SSH
      1. E2E testing
    2. C# .NET Core Deployment using SSH
      1. E2E testing
    3. Database
    4. Summary

Product information

  • Title: Continuous Integration, Delivery, and Deployment
  • Author(s): Sander Rossel
  • Release date: October 2017
  • Publisher(s): Packt Publishing
  • ISBN: 9781787286610