Continuous Integration with Jenkins, Maven and TestNg with Github on Linux/Ubuntu
- Quality Engineering
Continuous Integration with Jenkins, Maven and TestNg with Github on Linux/Ubuntu
First, Download the jenkins and install.
1. Download latest War file from the jenkins main site http://jenkins-ci.org/
2. Open Terminal and go to download folder and run
1 |
sudo java -jar jenkins.war |
3. Now jenkins fully up and running
4. Open http://localhost:8080/
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
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
7. Check on available plug in
8. Click on Next button
9. Accept the agreement and finish it
10. Will take few minutes to install maven than it will ask to restart eclipse, restart it
11. Install oracle java jdk 7
1 2 3 4 5 |
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java7-installer 8. Check installed java. java -version |
12. Check Java path
1 2 3 4 5 6 7 8 9 10 11 12 |
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 |
13. Check the java path
1 2 3 4 5 6 7 |
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
15. check “Use Default Workspace location”
16. Choose Quick start and click on Next button.
17. Fill data in Group id and Artifact id and Click on Finish
18. It will take some time and it will be ready for work (make sure Java SE version should be 1.7 )
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.
1 2 3 4 5 6 7 8 9 10 11 |
<?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 .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
<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
Auriga: Leveling Up for Enterprise Growth!
Auriga’s journey began in 2010 crafting products for India’s