Home/Continuous Integration with Jenkins, Maven and TestNg with Github on Linux/Ubuntu

Continuous Integration with Jenkins, Maven and TestNg with Github on Linux/Ubuntu

Published On: 28 May 2015.By .
  • Quality Engineering

First, Download the jenkins and install.

1. Download latest War file from the jenkins main site http://jenkins-ci.org/

 

Continious integration with jenkins and maven and testng on linux

2. Open Terminal and go to download folder and run

sudo java -jar jenkins.war

Continious integration with jenkins and maven and testng on linux

3. Now jenkins fully up and running

 

Continious integration with jenkins and maven and testng on linux  3

4. Open http://localhost:8080/

 

Continious integration with jenkins and maven and testng on linux 4

Configure Jenkins with Maven and TestNg
Configure Jenkins with Maven and TestNg

Configure Jenkins with Maven and TestNg

Installing maven

5. Open Eclipse and go to Help > Install New Software

 

Continious integration with jenkins and maven and testing on linux 5

6. Paste given link in “Work With” and click on “Add” button then will display a popup, click on Ok button.

http://download.eclipse.org/technology/m2e/releases

Continious integration with jenkins and maven and testing on linux 6

7. Check on available plug in

 

Continious integration with jenkins and maven and testing on linux 7

8. Click on Next button

 

Continious integration with jenkins and maven and testing on linux  8

9. Accept the agreement and finish it

 

Continious integration with jenkins and maven and testing on linux

10. Will take few minutes to install maven than it will ask to restart eclipse, restart it

11. Install oracle java jdk 7

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
8. Check installed java.
java -version


Continuous Integration with jenkins and maven and testing on Linux  10

12. Check Java path

 

echo $JAVA_HOME
if path displayed blank than run below commands
	1. first check your installation directory of java
	which java 
	2. will display 
/usr/bin/java
3. login to root 
sudo su
4. open bashrc file and end below at the end of file .
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export JRE_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre/bin
export PATH=$PATH:$HOME/bin:JAVA_HOME:JRE_HOME


Continuous Integration with jenkins and maven and testing on Linux 11

13. Check the java path

 

Java -version
 
now it will display 

java version "1.7.0_65" 
OpenJDK Runtime Environment (IcedTea 2.5.2) (7u65-2.5.2-3~14.04) 
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

14. Open eclipse

Go to New > Other software > Maven > Maven Project click on Next

 

Continuous Integration with jenkins and maven and testing on Linux  12

15. check “Use Default Workspace location”

 

Continuous Integration with jenkins and maven and testing on Linux 13

16. Choose Quick start and click on Next button.

 

Continuous Integration with jenkins and maven and testing on Linux 14

17. Fill data in Group id and Artifact id and Click on Finish

 

Continuous Integration with jenkins and maven and testing on Linux  15

18. It will take some time and it will be ready for work (make sure Java SE version should be 1.7 )

 

Continuous Integration with jenkins and maven and testing on Linux 16

19. Maven with Testng

In maven with testng we assume that you already are working in testng and upgrading to maven .

1. Create a maven project .

2. Except your test package copy all package to src/main/java

3. Copy your test package to src/main/test .

4. Configure your testng.xml file

e.g.

<?xml version="1.0" encoding="UTF-8"?>
<suite name="MyCol Front ">
	<parameter name="appURL" value="http://test.com/" />
	<parameter name="browserType" value="firefox" />

		<test name="CreateAnAccount">
		<classes>
			<class name="com.maven.tests.CreateAnAccounTest" />
		</classes>
	</test>
	</suite>

20. Configure pom.xml file

In Pom we have to write all dependencies that you are using in your project and plug in that you are using in your project .
See below code, if you using logging than you have to mention these dependencies .
If you are using another plugin that dependencies not displayed in pom than you should add it in pom file .

 

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>project</groupId>
	<artifactId>test</artifactId>
	<version>0.0.1-SNAPSHOT</version>

	<packaging>war</packaging>
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>
	<build>

		<plugins>
			<plugin>
				<inherited>true</inherited>	
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<encoding>UTF-8</encoding>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>2.18.1</version>
				<configuration>
					<suiteXmlFiles>
						<suiteXmlFile>testng.xml</suiteXmlFile>
					</suiteXmlFiles>
				</configuration>
			</plugin>
	
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-failsafe-plugin</artifactId>
			<version>2.18.1</version>

		</plugin>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-compiler-plugin</artifactId>
			<configuration>
				<source>1.7</source>
				<target>1.7</target>
				<encoding>UTF-8</encoding>
			</configuration>
		</plugin>
		<plugin>
			<groupId>org.eclipse.jetty</groupId>
			<artifactId>jetty-maven-plugin</artifactId>
			<version>9.2.11-SNAPSHOT</version>
		</plugin>
</plugins>

	</build>

	<dependencies>
		<dependency>
			<groupId>org.testng</groupId>
			<artifactId>testng</artifactId>
			<version>6.8.5</version>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.11</version>
		</dependency>
		<dependency>
			<groupId>org.seleniumhq.selenium</groupId>
			<artifactId>selenium-server</artifactId>
			<version>2.44.0</version>
		</dependency>
		<dependency>
			<groupId>org.seleniumhq.selenium</groupId>
			<artifactId>selenium-java</artifactId>
			<version>2.44.0</version>
		</dependency>
		<dependency>
			<groupId>org.seleniumhq.selenium</groupId>
			<artifactId>selenium-firefox-driver</artifactId>
			<version>2.44.0</version>
		</dependency>
		<dependency>
			<groupId>org.seleniumhq.selenium</groupId>
			<artifactId>selenium-java</artifactId>
			<version>2.44.0</version>
		</dependency>
		<dependency>
			<groupId>log4j</groupId>
			<artifactId>log4j</artifactId>
			<version>1.2.17</version>
		</dependency>
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi</artifactId>
			<version>3.10.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi-ooxml-schemas</artifactId>
			<version>3.10.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi-scratchpad</artifactId>
			<version>3.10.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-compiler-plugin</artifactId>
			<version>3.3</version>
			<type>maven-plugin</type>
		</dependency>
	</dependencies>
</project>

20. Right Click on Pom.xml >Run as > Maven Test

Related content

We Love Conversations

Say Hello
Go to Top