Set up Jenkins server for Selenium Regression Suite
In this article, I’m explaining the installation of Jenkins on the Windows server for continuous test automation. My regression suite is based on Selenium, TestNG, Java, and Maven, which is stored in a GitLab repository. Choromedriver will be used as WebDriver for this setup. The installation and configuration of each tool will be described below in detail.
Step 1: Install Java
- Download JDK (https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html)
- Install JDK on the new server (ex: jdk1.8.0_261)
- Set JAVA_HOME in environment variables (new system variable)
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_261
- Set JDK bin path in environment variables (add to existing PATH variable)
PATH=<existing values>;C:\Program Files\Java\jdk1.8.0_261\bin
Step 2: Install Git
- Download Git (https://git-scm.com/download/win)
- Install Git on new Server
- Set git cmd path in environment variables (add to existing PATH variable)
PATH=<existing values>;C:\Program Files\Git\cmd
- Setup Git environment (use Git Bash to enter below commands with your user name and email id)
git config --global user.name “Automation User”
git config --global user.email “auto.user@mailsrv.vm”
ssh-keygen -t rsa -b 4096 -C “auto.user@mailsrv.vm”
- Add above generated public key to GitLab user SSH Keys
Step 3: Install Maven
- Download Maven (https://maven.apache.org/download.cgi)
- Extract Binary zip archive (ex: apache-maven-3.6.3-bin.zip)
- Set maven bin path in environment variables (add to existing PATH variable)
PATH=<existing values>;C:\Program Files\apache-maven-3.6.3\bin
Step 4: Install Chromedriver
- Download Chromedriver (https://chromedriver.chromium.org/downloads)
- Extract Binary zip archive(ex: chromedriver_win32.zip)
- Set Chromedriver path in environment variables (add to existing PATH variable)
PATH=<existing values>;C:\MyWork\webdriver\chromedriver_win32
Step 5: Install Jenkins
- Download Jenkins (https://www.jenkins.io/download/)
- Install Jenkins as a service on the new Server with port 8080
- Load Jenkins URL (http://localhost:8080)
- Unlock Jenkins with initialAdminPassword (C:\Windows\System32\config\systemprofile\AppData\Local\Jenkins\.jenkins\secrets)
- Define password for admin user (inside “Manage Jenkins / Manage Users / Admin / Configure”)
- Setup Global Tool Configuration (inside “Manage Jenkins”)
- Manage Credentials (inside “Manage Jenkins”) (use the private key generated in Step 2)
Step 6: Setup Regression Job
- Create Job “Regression Test” for Maven Project
- Enter Repository URL and select Credentials
- Branch to build keep as “master” branch
- Set a periodically build schedule (ex: run at 6 pm on every Saturday)
- Enter root pom and maven goal with options
- Add a post-build action to publish TestNG Results
- Save settings and execute
Advantages of Automated Regression Test:
This Regression test will be automatically executed weekly as scheduled. You can change or include new tests to the regression suite without changing any configuration on Jenkins. Once you push new changes to GitLab, those changes will automatically reflect in the next test execution cycle.