Gulp: A DevOps Based Tool for Web Applications

0
3079

This article highlights the features of Gulp, an open source cross-platform streaming task runner that lets software developers automate many development tasks. It covers the installation of Gulp, and touches upon the code required for task and module management.

Software development teams need to work collaboratively on numerous tasks that are time consuming. DevOps is very popular in the corporate world for the automation, collaboration and real-time control that it enables on different types of software projects. Many corporate giants including Amazon, Oracle, Red Hat, SaltLake, Nagios, etc, use DevOps tools for real-world projects.

DevOps refers to the approach used to correlate the software development process with the various IT tasks to provide better software quality and streamlined deliveries. It speeds up the development, testing and deployment of code of high quality.

As the name indicates, DevOps is a combination of the development (Dev) and information technology operations (Ops) of an organisation that delivers software reliably, in a shorter time. The main purpose of DevOps is to automate the software development life cycle. The key features associated with DevOps are speed, reliability and better quality.

Agile development and enterprise systems management (ESM) make up the foundation of DevOps. Agile is linked to the software development process and ESM covers various processes that involve configuration management, system monitoring, etc. The need for DevOps arises because the operational team and development team work separately. The design, development and testing teams take more time and more errors occur during deployment.

Figure 1: Official portal of Gulp

The architecture of DevOps provides a combined approach for development and operations. This approach involves developing code, testing, planning, monitoring, deployment, operations and the release. This architecture is followed by large applications and those that are hosted on cloud platforms. This is because, in the case of large applications where the development and operational teams do not work in synchronised environments, long delays can occur in the process of design, deployment and testing. DevOps overcomes delays, maintaining high quality and timely delivery of the product.

The DevOps life cycle consists of seven phases which are: continuous development, continuous integration, continuous testing, continuous monitoring, continuous feedback, continuous deployment and continuous operations.

  • Continuous development: This includes a plan for the software and development processes.
  • Continuous integration: This consists of commit changes and integrated code from teams that have worked on the same project and have performed integration testing.
  • Continuous testing: During this process, the team identifies bugs in the code with the help of automated testing, which is more reliable and less time consuming than manual testing.
  • Continuous monitoring: This monitors all the processes that take place in different phases of the software development life cycle and records information regarding problems.
  • Continuous feedback: This improves subsequent versions of the software by removing what is not relevant according to the customer.
  • Continuous deployment: This involves code deployment on all the servers.
  • Continuous operation: This is the automation of the process and key operations.

DevOps based free and open source tools

DevOps provides a large variety of tools that are useful in the automation of the software development, testing and release processes. Table 1 lists some of these tools.

Gulp: An open source tool for Web applications

Gulp is used by software development teams as the streaming build system with which a number of tasks can be programmed and automated in an effective way.

Gulp is an effective task runner that has the strong base of the Node.js platform. It makes use of powerful JavaScript code for the execution of tasks and corporate level Web applications.

In Web development projects, the following are a few of the tasks required to be worked on continuously by the software development teams:

  • Formation, generation and transformation of templates
  • Compression of multimedia files
  • Code linting
  • Code validation
  • Integration of stylesheets and JavaScript code
  • Code generation for cross-browser compatibility
  • Deployment of files for staging and uploading to servers

Often, these tasks are repetitive in nature and require a lot of time. Gulp is a powerful and multi-featured tool that can be used to automate and speed up the tasks associated with software project development.

Installing and working with Gulp

To install and work with Gulp, you need to install Node.js. Once Node.js is installed, Gulp can be integrated with the following instruction:

$ npm install --global gulp

Once the installation is finished, the installed version can be verified as follows:

$ gulp -v

Table 1: Prominent DevOps tools

Tool URL
Gulp https://gulpjs.com
Worksoft https://www.worksoft.com
Kamatera https://www.kamatera.com
Buddy https://buddy.works
Nagios https://www.nagios.org
Chef https://chef.io
Jenkins https://www.jenkins.io
Vagrant https://www.vagrantup.com
Splunk https://www.splunk.com
Git https://git-scm.com/
Puppet https://puppet.com

Module management in Web applications using Gulp

The following is the hierarchy used for the files and folders while working with Gulp streaming applications.

src: Path of the pre-processed HTML code files:

Images: Uncompressed Images

Scripts: Assorted pre-processed scripts

Styles: Multiple Stylesheet Source Code in CSS format

Build: This folder is automatically created with the dynamic generation of production files:

Images:  Compressed image files

Scripts:  Script file with minified codes

Styles: CSS script with minified codes

gulpfile.js: Configuration file of Gulp in JavaScript for defining the tasks.

Task management and automation in Gulp

Gulp integrates the modular approach with task management so that the software development and related phases can be programmed with accuracy. You need to create a Gulp task with the following structure:

gulp.task(‘name of the task’, function() {
   // Operations
});

…where the name of the task refers to the title of the task. All the operations or tasks are defined in function(). The ‘gulp.task’ is used to register the function for the execution of the operations.

Here is an example:

gulp.task(‘mytask’, function() {

   var SourcePath = ‘src/myimages/**/*’, DestinationPath = ‘build/myimages’;

   gulp.src(SourcePath)

   .pipe(changed(DestinationPath))

   .pipe(mytask())

   .pipe(gulp.dest(DestinationPath));

});

The execution or running of the Gulp file is done using the following instruction:

$ gulp mytask

Today, large scale software projects have diversified teams of programmers, testing engineers as well as other team members. Hence, there is a need to automate and control tasks effectively so that companies can get fast delivery of the product, and to provide an integrated development environment with testing using the different tools of DevOps. The main requirement for the DevOps approach towards software development is that it should be cloud-centric so that simultaneous operations can be performed with the help of DevOps based tools and technologies. It is very difficult for small companies to follow DevOps because they can’t afford cloud costs. From the point of view of a career, DevOps is in huge demand in the software development job market, with a very good salary package on offer.

LEAVE A REPLY

Please enter your comment!
Please enter your name here