Protractor  – Gulp  –  Gradle  –  CI Jenkins


Well. If the topic grabbed you here, I assume you might be fascinated with any/all of the techy words in the topic or to get familiarize with those or simply bored. Without creating much Fuzz, let me tell in short that this article is about to discuss Integrating Protractor Automation Scripts with Jenkins ( CI – Continuous Integration Platform) using one of the efficient ways .

We could talk volumes on these tools/technologies but here we shall throw a little light over them before seeing how we can achieve the integration.

Protractor:  A test automation framework used to automate end-to-end testing of any Angular based web application. This comes with default “Jasmine” framework support (BDD framework).

Gradle:  A build automation/management tool used to build any type of software which eases using different script/programming  languages in a single project.

Gulp :  Gulp is task-streamer which supports multi platform. Gulp reads the files as stream and pipe them to different tasks. Gulp uses javascript configurations code . User can define task in a simple javascript functions

CI ( Jenkins ): Widely used Job scheduler/platform which almost support all platform projects to build and report. It supports variety of task execution environments through its plugins available in the web

From here, we going to discuss few Why’s (Essential part in the world of multiple choices)

Why Protractor – CI Integration Needed?

As protractor framework user, UI test automation scripts are going to be our deliverables.  Rolling out our product (Automation scripts) as Jenkins Job within (Testing team)/across team (UI Developers) helps anyone could use it without much dependency.  Test jobs can be added as part product development/deployment in automated way.  Build/Execution results and details history can be stored so that we can track/use them anytime down the line.

Why gradle?

We can bundle the Protractor scripts as a gradle project  and build them using gradle environment in our Jenkins (CI) nodes. Jenkins support gradle execution environment. We can execute the protractor scripts as gradle task.  Usually any build tool ( e.g  Maven ) can do this but what differentiate gradle from others , the target/Client nodes don’t need to have gradle by default. We can build gradle tasks using gradlewrapper. Gradlew unwraps gradle at any target machine first and execute gradle tasks. These reduces restrictions or dependencies of target machine’s execution environment setup

Why Gulp ?

We wrapped our Protractor automation project as a gradle project.  Gradle can execute gulp tasks in its build file. Gulp can read and execute protractor scripts which developed in javascript.  It allows to define run time parameters which received Gradle task  build variables also.

Integrating Protractor – Gulp – Gradle  – CI

This integration can be done in two simple steps

  • Define Gulp task for executing Protractor scripts in a JS file
  • Define Gulp parameters , Gulp task in your gradle build file

Defining Gulp Task for Protractor Scripts

Add a “gulpfile.js”  for defining gulp tasks. Make sure the name is right.  gulpfile should have the protractor paramters and tasks defined with gulp node commands. A detailed usage example given below.

The above js code act as gulpfile.  We covered run time parameters, webdriver update task, clean task and protractor execution as well.

Now we need to execute this gulp task in our gradle build file.

Define Gulp parameters , Gulp task in your gradle build file

In the build file ( Any gradle project would have this to define tasks in build phase), we need to add simple parameters and tasks to run this gulp task.

  • Include the necessary gulp plugin in your gradle project’s ‘build.gradle’  file.

  • Make sure that target machine get installed with NPM which is a pre-requisite for gulp to run. So include the  following line in your  ‘build.gradle’

  • Now to ensure that gulp installed for everytime the gradle task executed, add install gulp statement in your ‘build.gradle’

‘gulp_default’ referred in the example is a gulp task.

  • Give the current node module base where the current ‘build.gradle’ file exists

//    if the /node_modules directory already exists somewhere other than at the base of where //    your build.gradle is

  • Our plugin will search for this particular node_modules directory. So mention that in ‘build.gradle’ file

//  plugin looks for gulp in the node_modules directory

  • Now define the gulp task that you want to execute with extended options of passing external arguments as well in ‘build.gradle’

The following  is example of gulp task definition in ‘build.gradle’  file.



In above example

e2eTest –  Gulp Task Name   ,  ‘args’  supposed to have build phases like “  execute  “  and  external parameters can be given like “–env”,[“env”]. {–variable , value} combination.

Execution from Jenkins

  • Create a Job for Gradle project in Jenkins ( add gradle project plugin) .
  • Define the necessary parameters for the Build.
  • Mark the Root Build Script parameter to where the Parent folder of the project exists.
  • In the Build tasks, give your normal gradle tasks like clean & gulp task name defined in build gradle. From the above example , we can give

Other Ways

There are other ways available to integrate Protractor scripts with Jenkins. I listed few of them below.

  • Batch file of protractor commands and executing them from Jenkins
  • Execute the gulpfile with help of Jenkins gulp extension
  • Execute the protractor commands with other task streamer like grunt etc

We shall discuss about these ways detail in a separate space


I chose the gradle – gulp bridging way for Protractor-CI integration among many methods available to maintain the convention of my project’s other automation modules which are in gradle platform already. But people can choose based on their choice and conventions.

We start with our stand alone protractor scripts.  Created a gulp task file and defined our protractor tasks on it, called this gulp file in gradle’s task defining build gradle file. Wrapped this as gradle project and used in Jenkins. We can roll out the Jenkins job location to any intended people as a deliverable now.

Read More related links