Execute TestNG Tests in Jenkins

In previous tutorials we have seen executing testng.xml from batch file (.bat) which is an unformatted text file that consists of a series of commands to be executed by the command line interpreter. And we have also seen and executing testng.xml tests from command line,

Before proceeding, create any sample testNGProject, we have already created sample project here and we will execute the same tests here with jenkins help. After creating the sample project, project structure should look like below :

testng jenkins project

Now here we will see how to invoke batch file with Jenkins. Let us follow below steps to invoke .bat file from jenkins :

Step 1:
In Jenkins, you have an option to create 'New Job' Item, Click on it.

Step 2: -
Enter Job name and select "Free-Style Software Project" and then click on 'OK' button.

jenkins job name

Step 3: -
You should see header as 'Advanced Project Options' and with a button 'Advanced'. Now Click on "Advanced" option which will display multiple options.

Step 4: -
Select 'Use custom workspace' and specify your project location (workspace directory) in Directory

Step 5: -
Scroll down to see 'Build' option with 'Add Build Step'. In this drop down select value 'Execute Windows batch command' which Runs a Windows batch script for building the project. The text that we enter in the text box will be executed as a batch file. The script will run with the workspace as the current directory which we have specified in step 4.

jenkins job configure

Step 6: -
Click on Save button. New Job will be created with the configure options that we have defined.

That's It. We have Done.

Now we can execute job file by clicking on the 'Build Now' button which will invoke testng.xml from the batch file. Here the output looks after executing the job:

jenkins testng console output

Comments

I want setup my maven project on Jenkins using Root POM
How to take github pom.xml path in Root POM for build???

Add new comment