Cucumber works on Eclipse but not on Jenkins - java

I am successfully running Cucumber test on my java/maven eclipse project. But when I add my project do Jenkins I always get the following error "cucumber.runtime.CucumberException: No features found at []".
I read in this thread Setting cucumber-jvm options in Maven from the command line that:
...tests are running in separate JVM, so you need to specify that system property in the test plugin configuration (i.e. surefire or failsafe plugin config in your pom.xml)
But I am not quite sure how to do this. Can anyone help me?
PS: I am using "cucumber-java" and "cucumber-junit" dependencies.

If you're using surefire, the plugin documentation page http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html shows few options you can try to set system properties
For example you can try the systemPropertyVariables plugin settings

do you see the feature files in your target folder on your Jenkins slave ? maybe your *.feature files get excluded because of an incorrect config of your resources exclusion/inclusion in Maven ?

Related

Derive mandatory SonarQube properties from pom file in Jenkins with SonarQube Jenkins Plung

I just use the SonarQube-Plugin for Jenkins and configured the Jenkins job to execute the SonarQube Scanner. If I'm leaving the analysis properties in the UI and the sonar-scanner.properties blank the mandatory properties are missing. According to this question at least the sonar.projectKey should be automatically derived from the maven properties <groupId>:<artifactId>. If I set the sonar.projectKey and the sonar.sources properties directly everything works fine. But how can I achieve that the the maven properties <groupId>:<artifactId> are used by the plugin?
Edit: If I set the Analysis properties in the UI to:
sonar.projectKey=${POM_GROUPID}:${POM_ARTIFACTID} and sonar.sources=. as described here
it works fine. But it has no real advantage because I have to insert the same information to every job. It would be better if I can set these properties in a central file like the sonar-scanner.properties because all project dependent information is set by maven properties.
My configuration of the Post-Build-Step
For a Maven project, you should better use the scanner for Maven. Enable "Prepare SonarQube environment" feature and simply use a standard Maven step to run mvn sonar:sonar.
Documentation: https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Jenkins#AnalyzingwithSonarQubeScannerforJenkins-AnalyzingwithSonarQubeScannerforMaven

How to force Eclipse to use maven for automatic build

I am using Eclipse ,Spring,tomcat server,maven.
I need to pass some parameters when i build the project with maven.Everything works fine when i do that using command line or when i right click on POM.xml and run it making run configuration changes in eclipse.
But as soon as i start my tomcat it is not able to find the value i want to pass in the parameter and it gives an exception
: Could not open ServletContext resource [/WEB-INF/classes/properties/application-${spring.profiles.active}.properties]
here ${spring.profiles.active} should be replaced the the argument value.
So eclipse is not using maven with argument to build and deploy on the server automatically.
Insert the required maven plugins (especially maven-eclipse-plugin) in the pom.xml for compiling the code and use the command mvn eclipse:eclipse in the project's base directory. This will do the required stuff to create a maven project in eclipse.
This is a very complicated subject where many things can go wrong. You need to be very explicit of how you are running tomcat. Are you using wtp? WTP would be the panel that says "Servers". Is this spring boot? Do have the m2eclipse wtp plugin installed (its very hidden and not easy to find)?
One easier way to get this right is just use springs version of eclipse.

Maven project integration with Jenkins #selenium scripts

I am trying to run selenium scripts on Jenkins locally on my computer. I was using eclipse project and then i converted it to Maven by configure>convert to maven project. My Jenkins configuration is
Look at the configuration in the images. This is what I have done so far. I am a beginner to all this so don't know what I am missing. My console output on Jenkins is
Try this:
/user/Gauravgandhi/Documents/workspace/Applico/Website
for file system path and just pass pom.xml under Root Pom text box and define goals for the same.
I am hoping you configure JDK and Maven at jenkins level under configure jenkins link.
Please let me know if it works or not.
Gaurav,
Please make the setup using admin user in your machine or give full permission to your current user at every level.

How to config TestNG test-output folder to be inside Maven target folder?

Folks!
I'm new on TestNG, and I'm trying it with Maven (Surefire plugin) and Eclipse.
When my tests are run by Maven its reports are put on target/surefire-reports as expected, but the same tests when run by Eclipse TestNG plugin I'd like them to be put inside a target subfolder also (and as so be cleaned by clean Maven goal and ignored by git, not saying about respecting Maven folder organization), but always go to the default ${basedir}/test-output.
There is a way I can do it? I'd prefer one that I do not need to manually config Eclipse settings (Couldn't TestNG in detect it's a Maven project and so change its output folder consistently?), but if there is no such way, anyone surely will help.
TIA and regards,
Heleno
There is a no way that testng plugin can automatically figure out.
You can set your testng preferences at the workspace or project level. If you set it at the workbench level then for all projects, by default, testng would put the results there.
Go to Window->Prefs->TestNG.
Change Output directory to be same as maven output directory.
You can follow the way that niharika_neo told...
Elsewise you can also create timestamp enabled folder that would be created for every maven run you do, so won't let your testng reports bother you much. If still bothering put testng reports to a specific folder.
You can provide a different folder in your pom as --
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyyMMdd-HHmm</maven.build.timestamp.format>
</properties>
and under configuration of your maven-surefire-plugin put --
<reportsDirectory>./test-output/${timestamp}</reportsDirectory>
You will need to reconfigure XML Reporter as described at http://testng.org/doc/documentation-main.html#logging-xml-reports to set the outputDirectory property.
From that page:
In order to configure this reporter you can use the -reporter option
in the command line or the Ant task with the nested
element. For each of these you must specify the class
org.testng.reporters.XMLReporter. Please note that you cannot
configure the built-in reporter because this one will only use default
settings. If you need just the XML report with custom settings you
will have to add it manually with one of the two methods and disable
the default listeners.
It isn't clear how this translates into a configuration for the Maven Surefire plugin.
I had the same issue and I resolved it by going to Window-> Preferences -> TestNG
From there I check marked Absolute output path and entered the absolute path in the Output directory. For example C:\TestResults

Why doesn't ivyde see one of my dependencies?

I have an Eclipse build, using ivyde, that doesn't see one of my dependencies.
The build works fine in normal ant from the commandline.
The particular missing dependency is one of our own (not an Apache or more standard dependency). But again, it works from commandline ant builds just fine.
Maybe Eclipse uses some special defaults that don't exist in the command line version of pure ant ivy builds?
Make sure, that Eclipse/IvyDE-Plugin has the same settings as ant.
If you have a custom ivysettings.xml, make it known to eclipse. IvyDE will use it to resolve the dependencies. If it is not set maven repo is used as a standard.
You can configure the IvyDE settings like:
For debugging / errors you can open the ivy console and set its loglevel to debug.

Categories

Resources