Skip to main content

Protractor with Gitlab and Jenkins

Hi everyone.. welcome to the first article in my new series of articles on Automation Testing. For a change, let's start from the End. Let's assume you have written your automation code in protractor and your project is ready to be pushed in to the repository.

So let's start with a brief introduction on how to push our automation code to a Git repository. In this lesson I will be using GitLab repository.


First things first.. You can't just push the code to a repository. Yeah.... you have to install Gitlab and make sure you have configured it properly. Try following command to make sure Git have been installed in your machine.

git --version
Hope Git have been installed in your machine, Let's start with GitLab configuration.
  • Sign up with GitLab account
  • Go to GitLab account and get register with your email account
  • To identify you as the author configure your Git username and email address in your machine
git config -- global user.name
git config -- global user.email
  • Then create a new project under GitLab account.
  • Clone the repository in to your local environment using one of the following commands.
git clone git@gitlab.com:thuvvashan20/testscripts.git
git clone https://gitlab.com/thuvvashan20/testscripts.git
  • Copy your protractor project directory in to your cloned path.
  • To check the changes you've made in the project try the following command.
git status
  • Add the directory to the Git repository.
git add .
  • Commit the local changes.
git commit -m "Description regarding the commit"
  • Push the code to the Git repository.
git push -u origin master

  • Now you can see the code with the committed message in your remote GitLab project directory.

Jenkins configuration

Jenkins can be downloaded from this site. Download the latest war file.
  • Deploy the Jenkins war file using below mentioned command,Go to the directory location where you have copied the war file.
java -jar jenkins.war
  • You can see an encrypted password n the terminal, Copy the one time password.
  • Once the process is completed, you can see the following information.
INFO: Jenkins is fully up and running
  • Now you should be able to access Jenkins via the link http://localhost:8080/
  • Paste that one time password and continue it.
  • You can select any of the plugin installation options. To keep it simple I'm going to select 'Installed suggested plugins'.
It will take some time to install the plugin, wait until it got completed
  • Once the installation is completed, It will prompt a page to register the Jenkins user details.

  • Now you can login to Jenkins dashboard by providing the credentials.
  • To integrate Jenkins with GitLab we should install the GitLab plugin.
Jenkins -> Manage Jenkins -> Manage plugin -> GitLab

Once the installation is completed it will appear under Available tab
  • Restart the Jenkins.
After this we have to add GitLab credentials to server in order to make the connection between our protractor code and Jenkins.

Add GitLab credentials to Jenkins

  • Add GitLab username and password.
Jenkins -> Credentials -> System -> Global Credentials -> Add Credentials

Add GitLab username and password
Now the connection between GitLab and Jenkins is setup, we need to create a freestyle job to run the code which resides in GitLab.

Create a Job in Jenkins

Jenkins -> New item

Create a new item
  • Create a free style project by providing a name.
  • Select a option as Git under Source Code Management.

  • Specify the remote Git repository path with the extension .git in Repository URL.
  • Add the credentials which you have already setup under Global credentials.
  • To Build the project, you should provide the Protractor config file.
      Build -> Execute shell


  • Your first Jenkins job is all set to run. You can start build by clicking on the schedule button in corner.


  • You will be able to view the protractor code under the workspace.

  • Once it fetches the code, It will start to execute your e2e test scripts.

Comments

Popular posts from this blog

GitLab and Jenkins configuration through SSH

In my previous post I have mentioned how to integrate GitLab with Jenkins using username and password. Now we will learn how to configure Jenkins and GitLab using SSH connection. Login as Jenkins user sudo su - jenkins Run the following command to generate SSH key,  ssh - keygen Now it will create  a directory named .ssh if it doesn't exist, Press enter and re-enter when you are prompted to enter passphrase. thuvvareka : ~ jenkins$ ssh - keygen Generating public / private rsa key pair . Enter file in which to save the key ( / Users / Shared / Jenkins / . ssh / id_rsa ) : Created directory ' /Users/Shared/Jenkins/.ssh ' . Enter passphrase ( empty for no passphrase ) : Enter same passphrase again : Your identification has been saved in / Users / Shared / Jenkins / . ssh / id_rsa . Your public key has been saved in / Users / Shared / Jenkins / . ssh / id_rsa . pub . The key fingerprint is : SHA256 : O9APiAETUYC87e9T6k18SPFQxEN4R2gJbKG6JLOID64 jenkins@thu...

Mobile Test Automation using Appium and Android studio

In this article we will discuss about how to automate Mobile application using Appium Server and Android Studio. Appium supports both iOS and Android. Appium is HTTP server. It receives the commands from client, executes the command on Mobile device and send a HTTP response representing the result of the command execution. I am going to use Android studio to create a virtual emulator. And Selenium WebDriver will be used to write the Client. I would prefer to use the virtual emulator instead of using real device. In actual devices you may find difficulties to connect/detect it. Pre-requisites .apk file is required to install in Mobile device (Virtual emulator). Android Studio, Appium desktop server and intelliJ IDEA have to be installed. Virtual emulator This post guides you to create the Virtual emulator using Android Studio. Once you launch the emulator now It's time to install the mobile application which is going to be automated. Drag and drop the apk file ...

Katalon studio Execution Profiles

Hi Folks, I want to share my experience regarding the learning, My project manager asked me to find the best way to automate the web application for the regression/retest purpose. So I had a research on the tools and technologies regarding automation. So I found this :) In this post I would like to share my knowledge on Katalon Studio Profiles.  Let's have a quick idea regarding Katalon studio. Katalon studio is a free automation testing tool and supports the web and mobile environment, and built on top of the open-source automation frameworks Selenium, Appium with a specialized IDE. Pre requests - You can download Katalon studio from this link. I am using the latest version in order to avoid unnecessary errors. First, I will show how to record the Web application via Katalon studio. Find below mentioned test scenarios which are going to be recorded Launch the application (URL : http://demoaut.katalon.com/ ) Make an Appointment Login using provided credentials...