Jenkins fails build but on local machine everething is ok - jenkins

[INFO] Fork Value is true
[java] The following errors occurred during analysis:
[java] Aug 09, 2013 3:16:04 PM edu.umd.cs.findbugs.TextUIBugReporter reportAnalysisError
[java] SEVERE: Unable to get XClass for java/lang/StringBuilder
...
After these messages Jenkins ends build with failure. On local machine i got these messages too, but nothing interrupts, and findbugs, pmd and checkstyle finish correctly.
Also on Jenkins i got
[PMD] No report found for mojo check
[FINDBUGS] No report found for mojo check
, but on local machine i don't. Seems like these two stranges are linked, how can i fix them?
I run mvn verify.
SCA included in pom.xml in build section like
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<skip>false</skip>
<failOnViolation>false</failOnViolation>
<failOnError>false</failOnError>
<xmlOutput>true</xmlOutput>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>findbugs</goal>
</goals>
</execution>
</executions>
</plugin>

The problem was in different jdks. On local machine i have 1.7, but on Jenkins - 1.8, so i simply changed version. And seems like roots of this bug are in jdk 1.8.

apparently, the class structure changed in Java 8. Therefore, FindBugs version 2.0.3 (latest release as of 1. Mai 2014) and earlier fail on classes compiled on JDK 1.8 (or later). They already fixed this in the FindBugs development version (not released as of 4. May 2014). The latest maven plugin (findbugs-maven-plugin:2.5.3) uses FindBugs 2.0.2.
I decided to generate the maven reports with Java 7, until the fix (and a new FindBugs maven plugin version using it) is released.
to generate the reports with Java 7 (linux):
JAVA_HOME=${HOME}/Software/jdk1.7 mvn site
related FindBugs bug reports:
http://sourceforge.net/p/findbugs/bugs/1271/
http://sourceforge.net/p/findbugs/bugs/1264/

Related

cargo-maven2-plugin:start fails with "Actually there are no valid types registered for this configuration", regardless of what containerId I enter

I'm trying to run integration tests with the cargo-maven2-plugin and Tomcat 8. I want the Maven build to start the container for me, so I have configured the start and stop goals as documented here. The problem is that regardless of what I enter as containerId, the start goal always fails with a message saying that there are no registered configurations. The error messages always ends in
Actually there are no valid types registered for this configuration. Maybe you've made a mistake spelling it?
I've tried various configurations, including ones that I found in various tutorials, and ones that user older Tomcat versions, but nothing helps. The error message is always the same.
Other posts here on Stack Overflow recommend to update the Cargo versions, but this doesn't apply to my problem: I already use the latest release version (1.6.5).
So, why do I keep getting this error?
For reference, here is one complete configuration that I tried out:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.6.5</version>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<container>
<containerId>tomcat8x</containerId>
<artifactInstaller>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat</artifactId>
<version>8.5.23</version>
</artifactInstaller>
</container>
<configuration>
<type>standalone</type>
</configuration>
<deployables>
<!-- ... -->
</deployables>
</configuration>
</plugin>
The full error message for this configuration is:
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.6.5:start (start-container) on project domain.db.itest: Execution start-container of goal org.codehaus.cargo:cargo-maven2-plugin:1.6.5:start failed: Cannot create configuration. There's no registered configuration for the parameters (container [id = [tomcat8x], type = [installed]], configuration type [standalone]). Actually there are no valid types registered for this configuration. Maybe you've made a mistake spelling it? -> [Help 1]
The solution was incredibly simple: I had the offline mode enabled. Without offline mode, Cargo downloaded the cargo-core-container-tomcat artifact, and apparently this artifact contains the definition of the tomcat8x configuration. Then, the container start was successful!
I had started the Maven build from Eclipse, so I didn't notice that the offline mode was enabled. I'm aware that this situation is quite special, but maybe someone else still benefits from my insight. It took me a while to solve, so I'm sharing problem and solution here. (After all, this is encouraged :-)
I got the key hint from a mailing list post, where thecargo-core-container-tomcat artifact was not downloaded due to a Nexus repository configuration.
This error is sometimes due to the cargo plugin version. Update your cargo plugin to the higher or latest version.
In my case, I updated from cargo 1.4.8 to cargo 1.7.0.
check this link,its may help:
click here

JENKINS: ERROR when I try to use an older JDK for a specific maven project

I am using the Jenkins version 2.73-1.1 on a CentOS Linux release 7.3.1611 server.
There are 3 different versions of JDK on the server:
[root # jenkins java] # ll
total 12
lrwxrwxrwx. 1 root root 16 27 Apr 16.25 default -> / usr / java / latest
drwxr-xr-x. 8 root root 4096 27 Mar 2013 jdk1.6.0_45
drwxr-xr-x. Root root 4096 11 Apr 2015 jdk1.7.0_80
drwxr-xr-x. 9 root root 4096 27 Apr 16.25 jdk1.8.0_131
lrwxrwxrwx. 1 root root 22 27 apr 16.25 latest -> /usr/java/jdk1.8.0_131
As shown in the pictures below, Jenkins is using the jdk1.8.0_131 version and in my project I specified to use JDK7.
Jenkins setup Image 1
Jenkins setup Image 2
When I try to compile my project (mvn clean deploy), the build fails and I see this ERROR in log:
[Vodafone] $ /usr/java/jdk1.7.0_80/bin/java -cp
/var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.11.jar:/opt/apache-maven-3.0.4/boot/plexus-classworlds-2.4.jar
org.jvnet.hudson.maven3.agent.Maven3Main /opt/apache-maven-3.0.4
/var/cache/jenkins/war/WEB-INF/lib/remoting-3.10.jar
/var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.11.jar
/var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.11.jar
46349 <===[JENKINS REMOTING CAPACITY]===>channel started ERROR:
================================================================================ ERROR: Invalid project setup: jenkins/security/MasterToSlaveCallable :
Unsupported major.minor version 52.0 ERROR:
[JENKINS-18403][JENKINS-28294] JDK 'JAVA7' not supported to run Maven
projects. ERROR: Maven projects have to be launched with a Java
version greater or equal to the minimum version required by the
master. ERROR: Use the Maven JDK Toolchains (plugin) to build your
maven project with an older JDK. ERROR: Retrying with slave Java and
setting compile/test properties to point to /usr/java/jdk1.7.0_80.
ERROR:
================================================================================ Established TCP socket on 38129 [Vodafone] $
/usr/java/jdk1.8.0_131/jre/bin/java -cp
/var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.11.jar:/opt/apache-maven-3.0.4/boot/plexus-classworlds-2.4.jar
org.jvnet.hudson.maven3.agent.Maven3Main /opt/apache-maven-3.0.4
/var/cache/jenkins/war/WEB-INF/lib/remoting-3.10.jar
/var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.11.jar
/var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.11.jar
38129 <===[JENKINS REMOTING CAPACITY]===>channel started
Why Jenkins doesn't use jdk 7?
As it is documented on the maven project plugin of jenkins home page:
Jenkins >= 2.54 requires Java 8 thus Maven jobs must be launched with Java >= 8
Luckily the best workaround is just mentioned in your stacktrace:
... Use the Maven JDK Toolchains (plugin) to build your maven project with an older JDK...
In order to compile your project using java 7 and launching successful jenkins job using current jenkins version, I would recommend you to use this plugin by 2 simple steps:
Add toolchains.xml file to your .m2 directory both on developers system and jenkins server
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>1.7</version>
<vendor>openjdk</vendor>
</provides>
<configuration>
<jdkHome>/usr/lib/jvm/java-7-openjdk-amd64</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>1.8</version>
<vendor>openjdk</vendor>
</provides>
<configuration>
<jdkHome>/usr/lib/jvm/java-8-openjdk-amd64</jdkHome>
</configuration>
</toolchain>
[...]
</toolchains>
Add toolchain plugin to your project pom file
<project>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>1.7</version>
<vendor>openjdk</vendor>
</jdk>
</toolchains>
</configuration>
</plugin>
</plugins>
</build>
</project>
Finally config your jenkins job to use jdk 8, toolchain will take care of compiling your project with jdk 7.
Try configuring a Freestyle Job in Jenkins. You will need to select the "Invoke top-level Maven targets" build. I was having a similar problem. This worked for me.

Jenkins:can not see test report tab

I can not see report tab here:
Public Junit test report:
I have configured Public JUnit test report, but I still can not see test report in left area.
As the OP joan.li adds in the comments, you need to make sure Your Jenkins installation knows about maven (as mentioned in "Jenkins executing maven from incorrect path"):
Add the default maven installation under (Jenkins -> configuration)
Goto the failing job and make sure you choose the default maven installation from dropdown
And You need to make sure your pom.xml does include a surefire build step
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
See also this example.
Check if those xml files are generated

Enunciate multiple time running with maven

I'm using enunciate 1.27 and maven 3.0.4 .
My problem occurs when I run enunciate multiple times :
[INFO]
[INFO] --- maven-enunciate-plugin:1.27:assemble (number2) # yaghut-web ---
[INFO] initializing enunciate.
[INFO] [csharp] C# compilation is disabled, but the source code will still be generated.
[INFO] invoking enunciate:generate step...
An exception has occurred in apt (1.6.0_30). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.NullPointerException
at com.sun.tools.apt.comp.Apt$AptTreeScanner.visitAnnotation(Apt.java:161)
at com.sun.tools.javac.tree.JCTree$JCAnnotation.accept(JCTree.java:1794)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:33)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:41)
at com.sun.tools.javac.tree.TreeScanner.visitModifiers(TreeScanner.java:266)
at com.sun.tools.javac.tree.JCTree$JCModifiers.accept(JCTree.java:1816)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:33)
at com.sun.tools.javac.tree.TreeScanner.visitClassDef(TreeScanner.java:60)
at com.sun.tools.apt.comp.Apt$AptTreeScanner.visitClassDef(Apt.java:146)
at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:575)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:33)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:41)
at com.sun.tools.javac.tree.TreeScanner.visitTopLevel(TreeScanner.java:52)
at com.sun.tools.apt.comp.Apt$AptTreeScanner.visitTopLevel(Apt.java:124)
at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:446)
at com.sun.tools.apt.comp.Apt.main(Apt.java:213)
....
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
I execute enunciate in this way:
<execution>
<id>number1</id>
<goals>
<goal>assemble</goal>
</goals>
<configuration>
<configFile>src/main/enunciate_number1.xml</configFile>
<compilationEncoding>UTF-8</compilationEncoding>
<generateDir>${project.build.directory}/enunciate/number1/generate</generateDir>
<compileDir>${project.build.directory}/enunciate/number1/compile</compileDir>
<buildDir>${project.build.directory}/enunciate/number1/build</buildDir>
</configuration>
</execution>
<execution>
<id>number2</id>
<goals>
<goal>assemble</goal>
</goals>
<configuration>
<configFile>${project.basedir}/src/main/enunciate_number2.xml</configFile>
<compilationEncoding>UTF-8</compilationEncoding>
<generateDir>${project.build.directory}/enunciate/number2/generate</generateDir>
<compileDir>${project.build.directory}/enunciate/number2/compile</compileDir>
<buildDir>${project.build.directory}/enunciate/number2/build</buildDir>
</configuration>
</execution>
when I executed enunciate one time (I mean omit number2) everything work correctly.
I guessed 'generateDir' in second execution was not set correctly. When I omit it, nothing was generated (message was: everythis appears up-to-date); and with current configuration, NullPointerException is thrown.
any idea?
thanks.
I don't know much about how to configure Maven to get this right, but an alternative approach might be to use the maven-antrun-plugin to invoke Enunciate twice instead of trying to get Maven to do it. The configuration would look kinda like the contents of the "getting-started-examples" target at line 199 in build-site.xml.

Generating multiple javadoc reports using maven-javadoc-plugin and Maven 3

We use a custom doclet to generate a report from custom javadoc tags, and use the Maven site plugin and javadoc plugin to generate both this report and the regular java API docs.
The section of the POM looks like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<reportSets>
<reportSet>
<id>html</id>
<reports>
<report>javadoc</report>
</reports>
</reportSet>
<reportSet>
<id>custom_report</id>
<configuration>
...
</configuration>
<reports>
<report>javadoc</report>
</reports>
</reportSet>
</reportSets>
</plugin>
Under Maven 2, this works fine, but in Maven 3 only one report is generated, that being the last one specified in the POM (confimed by swapping the reportSet elements).
After some experimenting I discovered that if I changed the regular report's goal from "javadoc" to "test-javadoc", then I got output from both report sets. So the problem seems to be that with Maven 3 I can't generate two reports that use the same javadoc-plugin goal.
Is this a bug, or is there some congifuration I've missed? I moved the maven-javadoc-plugin setup from reporting to the configuration of the site plugin as described at http://maven.apache.org/plugins/maven-site-plugin-3.0-beta-3/maven-3.html, to no avail. I'm using Maven 3.0.4, maven-site-plugin 3.0-beta-3 and maven-javadoc-plugin 2.8.1.
Thanks!
It's a bug in maven-reporting-exec component.
Report sets are kept in a map using the report goal as a key.

Resources