How to integrate Gradle jmeter plugin with jmeter + jenkins - jenkins

How to locate build.gradle file ?. Under which folder i need to create build.gradle file ? I am saving all my .jmx test files under jmeter/bin folder
Do i need to create a new java project in IDE to use Gradle?
Please provide detail steps to integrate Gradle jmeter plugin with jmeter + Jenkins

To create a standalone gradle project that runs jmeter tests, you can create a new folder and add a file build.gradle to it, with the following contents:
plugins {
id "net.foragerr.jmeter" version "1.0.3-2.13"
}
Create a folder src/test/jmeter and place all your test .jmx files there.
From jenkins you can run gradle jmrun to run tests and gradle jmreport to generate reports.

Related

Jenkins build without maven

I have a java project which I build and export it as a jar using eclipse. Then I deploy the jar.
Also my project uses dependencies e.g. Apache POI etc. I include these jars in the build path and then clean build and export it as a jar.
I want to build the jar using Jenkins. Please suggest the script and command to perform the same task without using maven. I have to build the code from Gitlab.

test-output folder is not created when i execute maven project in jenkins

I have selenium project created using Maven. I have included surefire plugin also . When i execute the "mvn test" command using jenkins . I am not able to see the test-output folder . Could you please help me to fix it
TestNG would create the output folder as test-output only when running it via the IDE such as eclipse or IntelliJ.
When you run TestNG tests via Maven using surefire plugin, then the output folder is controlled by surefire plugin which is passed on to TestNG as part of the initialization.
By default surefire reports are available under target/surefire-reports folder where target folder is the default build output folder.
You can customize or change this folder value via https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#reportsDirectory
After executing test script then
Right click on your project folder into eclipse and click on refresh
button. test-output folder will appear in TestNG

how to run Selenium tests in Jenkins

I want to run my Selenium Webdriver Maven tests in Jenkins. I've followed the tutorial: https://www.guru99.com/maven-jenkins-with-selenium-complete-tutorial.html and https://www.safaribooksonline.com/library/view/jenkins-the-definitive/9781449311155/ch04s06.html
But now, I want to run each of hundreds tests that I've written in Selenium Webdriver with Eclipse.
I use Maven to create testng.xml (where I have my Maven projects to can execute a list of tests in the same execution).
I use Eclipse to write Java to create tests in Selenium Webdriver.
I use github to import tests.
I show you my github project... I don't know how to access into the different folders to execute each testng.xml files, sorry, I'm pretty new here.
Could anybody help me with this issue?
Thanks so much!!!!
Create a freestyle Jenkins job and then go to the configuration page of your job and in Source Code Management section add the URL of your Git repo where you have kept your TestNG tests. This will help to bring the tests from the repository to your workspace.
Then go to the Build section and select Execute windows batch script if and then add the following script:
java -cp ".;/path/to/testng-x.x.x.jar;/path/to/jcommander-x.xx.jar;/path/to/test-classes" org.testng.TestNG /path/to/test.xml
For Linux use the following script with Execute shell in `Build step:
cd /path/to/test.xml
java -cp "/path/to/testng-x.x.x.jar:/path/to/bin" org.testng.TestNG testng.xml
Where /bin folder contains the compiled code for the TestNG tests.
Then save the job and run the build to execute TestNG test cases.
Note: You can find the required JAR files inside the .m2 folder.

Change directory during a build job on jenkins

I am building a gradle project and the source code is in git. After checking our repo to jenkins' workspace, how do i have jenkins go to a sub-directory and do the build?
I tried adding shell commands but cd will not work as it executes script on a separate shell.
If you are building a gradle project, perhaps you should use the "Invoke gradle script" step rather than a shell script?
As part of the gradle build script, it has an option to specify the "Root Build script", which will let allow you to specify a subdirectory if you wish.
See the Gradle plugin for more information.

How can I build a Netbeans RCP application with SBT?

Netbeans RCP application are built with Ant. How can I build with SBT and integrate in Jenkins?
There's a SBT plugin which allows Ant targets to be called.
First build ant4sbt from sources:
git clone http://github.com/sbt/ant4sbt.git
cd ant4sbt
sbt publish-local
Create a file properties/sbt-ant4sbt.sbt like this:
addSbtPlugin("de.johoop" % "ant4sbt" % "1.1.2")
Create a build.sbt on the root of your Netbeans RCP application:
import de.johoop.ant4sbt.Ant4Sbt._
antSettings
addAntTasks("build-osgi") // creates task antRunBuildOsgi
addAntTasks("run-osgi") // creates task antRunRunOsgi
Now you can build OSGi bundles from command line and run it inside a container, like this:
sbt antRunBuildOsgi
sbt antRunRunOsgi
Building in Jenkins is as easy as calling sbt antRunBuildOsgi but you will have to copy dependencies to the library directory you defined in your Netbeans IDE. After the build you will also have to copy artifacts to the place you distribute artifacts of your builds.
See also: Cannot build OSGi bundle for a Netbeans RCP application

Resources