Protractor-Grunt CI Pipeline on Jenkins Server

 

Protractor-Grunt CI Pipeline on Jenkins Server

 

Jenkins is a powerful open source tool that provides facility to perform continuous integration which ends up in automated testing on the most recent build and determine error once the build is completed.

In this blog, we are going to discuss the way to globally set up Jenkins, the way to create a new Jenkins job and set up it using varied plugins like GIT, EMail, Reporting etc.

In most of the cases, we’ve to run our test cases on the server rather than the local environment. during this case, we’ve to set up Jenkins on server machine rather than localhost.

Pre-requisites:

Install Google Chrome:

wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -

echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | sudo tee /etc/apt/sources.list.d/google-chrome.list

sudo apt-get update 

sudo apt-get install google-chrome-stable

Install ChromeDriver:

sudo apt-get install chromium-chromedriver

Jenkins Plugin Installation:

Click on Manage Jenkins. it’ll send the user to http://testingalertjenkins.net:8080/manage

Click on Manage Plugin. it’ll send the user to http://testingalertjenkins.net:8080/pluginManager/

Click on “Install plugin”.

Click on “Available tab”.

Install below-mentioned plugins:

==============================================================================

 

Setup Global tool configuration:

First of all, we’ve to perform some global configuration which can be shared amongst all the Jenkins jobs.

Click on Manage Jenkins –> Configure System

Go to http://testingalertjenkins.net:8080/configure

As the name suggests, this setup is required for all the jobs.

Click on “Global Tool Configuration”

Setup JDK:

Setup GIT:

Install GIT plugin.

Setup Chrome:

Install Latest version of Google Chrome on Jenkins server.

Setup Maven:

Setup NodeJS:

 

Setup Allure Commandline:

==================================================================

Restart Jenkins:

Go to http://testingalertjenkins.net:8080/restart

Click on Restart Once No Jobs Are Running.

==================================================================

 

Create New Jenkins Job:

 

 

Enter Project name. (Please try to avoid spaces in between names, therefore, use underscores(‘_’).

 

Click on Save.

Setup GIT:

Delete Workspace

 

Build

==================================================================

Execute Shell

echo `which npm`
 echo $PATH
 export DISPLAY=:1
 node --version
 npm --version

# Enter into your project directory

cd TestingAlertQA
 npm cache clean
 npm install

 grunt --version #Check for installed Grunt version
 java -version   #Check for installed Java version
 google-chrome --product-version #Check for installed Google Chrome version

 npm update  # Update project dependencies
 npm run clean # Clean previously stored 
 npm run status # webdriver-manager status
npm run update 
npm run status 
#node ./node_modules/protractor/bin/webdriver-manager update 

#Maven configuration - 
export MAVEN_HOME='/usr/local/share/apache-maven-3.3.9' 
alias mvn=${MAVEN_HOME}/bin/mvn 
mvn -version 

NODE_ENV=${ENVIRONMENT} NODE_USERTYPE=${USER_TYPE} npm test 
#NODE_ENV=${ENVIRONMENT} NODE_USERTYPE=${USER_TYPE} npm run a-test 
#NODE_ENV=${ENVIRONMENT} NODE_USERTYPE=${USER_TYPE} npm run e2e conf. 

==================================================================

Post-build Actions

In post build section we will configure Allure Report plugin.

Setup Allure Report in Job:

====================================================================================

Setup VNC:

sudo apt install xfce4 xfce4-goodies tightvncserver

Provide a password to access VNC

Configure VNC:

Go to /etc/vncserver/vncservers.conf and enter below configuration.

VNCSERVERS="1:jenkins"
VNCSERVERARGS[1]="-geometry 1024x768"
When VNC is first set up, it launches a default server instance on port 5901. This port is called a display port and is referred by VNC as :1
One time restart is required:
vncserver -kill :1

Steps to launch VNC:

  • Open Remmina.
  • Select VNC
  • Enter server IP with:1 e.g. 14.8.188.343:1 or 5901 as port address and then click on connect.
  • It will ask for the password.
  • After entering the password, click on connect.

Allure Report

Allure Report is provided by Allure Plugin which is used to employ a user-friendly report.It is a flexible, lightweight multi-language test report tool, with the possibility of adding to the report of additional information such as screenshots, logs and so on. It is a great degree simple to use and makes excellent execution reports.

 

 

After clicking on Allure Report. It will look like:

Leave a Reply

%d bloggers like this: