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.
Now the connection between GitLab and Jenkins is setup, we need to create a freestyle job to run the code which resides in GitLab.
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
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
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 |
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
Post a Comment