Jenkins Setup for PHP unit testing and selenium framework on AWS

Please visit my website and subscribe to my youtube channel for more articles

Login to AWS EC2 Linux Instance

Install Java : Click Here for more details

Install Jenkins : Click here for more details

Open the url in the browser. Default port is 8080


It will ask for the initial password, please run the below command

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Jenkins setup with windows agent is completed successfully.

Now to run any job on windows slave, you have to provide the label as “windows” in any Jenkins job as shown below

Integrate Jenkins with Gitlab

Go to GitLab ->Profile Settings

Then, click “Access Token” and create a Jenkins API Token

Then, save and copy this API Token. You won’t be able to access it again

Install Plugins in Jenkins

Manage Jenkins -> Manage Plugins -> Gitlab,gitlab hook,junit,testng results

Configure the Jenkins Server with Gitlab Server

Go to Manage Jenkins -> Configure System and scroll down to the ‘GitLab‘ section. Write a custom connection name, enter the GitLab server URL in the ‘GitLab host URL‘ field and click Add -> Jenkinsbutton.

Then, fill required fields as shown below with the Jenkins Access API Token which we created in GitLab before.

Then, select this API Token credential and finally click “Test” and see the “Success” message as shown below

Setup SSH connection between Jenkins and Gitlab

Run on Jenkin Server

cat /home/ec2-user/.ssh/

Go to Gitlab setting -> SSH Keys -> paste the key

Jenkins ->Credentials -> Add Crdentials -> SSH username with private key

Copy key from here cat /home/ec2-user/.ssh/id_rsa

SSH setup is completed successfully.

Configure Windows Agent to clone git repo.

Manage Jenkins -> Manage Nodes -> Windows Node — Configure -> Add Tools Location

Configure Java and Git ( Installed Java and Git manually on windows agent)

Configuring webhooks in GitLab

This will trigger the Jenkins job as an when there is a push in the repository

Go to specific project in gitlab-> click on settings ->integration as shown below

Put the jenkins job project url and all default setting

Click on test and push events

All configuration is setup successfully.

Now we will create a jenkins job for running selenium test case

Create a Freestyle job in Jenkins

Set Label that this job will run only on windows agent

Job Successfully completed. Click on Build now and see the results.

Setup for PHP Unit test cases

Install php and phpunit on linux jenkins server

Manage Plugins -> Junit (if not already installed)

Create a freestyle project

/usr/local/bin/phpunit — log-junit test.xml -c phpunit.xml .

Job is successfully setup.

Devops Automation Enginneer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store