patst
patst

Reputation: 123

Hudson SonarPlugin fails if MAVEN_OPTS are set in build job

I configured a post build sonarqube analysis with the hudson SonarPlugin. I configured the MAVEN_OPTS for the SonarPlugin to be like this: "-Xmx1024m -Dmaven.javadoc.failOnError=false"

If I run the job there is an error when hudson tries to execute the post build action:

[workspace] $ mvn -f /home/hudson-3.3.0/jobs/myJob/workspace/pom.xml -e -B sonar:sonar -Dsonar.jdbc.driver=oracle.jdbc.OracleDriver -Dsonar.jdbc.url=jdbc:oracle:thin:@xxxxx:1521/xxxx ******** ******** -Dsonar.host.url=http://xxxx:9000/sonar
Error: Could not find or load main class MAVEN_OPTS
Sonar analysis completed: FAILURE

I use the following setup:
Tomcat 8.0.24
Hudson 3.3.0
Sonar-Plugin 2.0.1
Maven 3.0.5 / 3.2.5
JDK 1.7.0_45

On a older hudson version with Sonar-Plugin 1.8.1 the build worked.

As workaround I configured my MAVEN_OPTS path variable to contain the expected settings but since I have to configure different jobs with different settings this is only a workaround.

Anybody got an idea how to fix this issue?

Upvotes: 2

Views: 559

Answers (2)

Boris
Boris

Reputation: 4537

While dur's solution works fine, it has the downside of having the "build now" link asking for the build parameter instead of just building.

To get it working without the need for an parametrized build, I changed hudson's $HOME/.mavenrc to contain the following line:

export MAVEN_OPTS="$(echo ${MAVEN_OPTS} | sed -e 's#^MAVEN_OPTS ##')"

This strips the leading "MAVEN_OPTS" from the MAVEN_OPTS variable. So if hudson/the plugin is setting MAVEN_OPTS="MAVEN_OPTS -Xmx128m" this mavenrc will change MAVEN_OPTS to contain just -Xmx128m.

Upvotes: 1

dur
dur

Reputation: 16969

As you can read in Bug 474406 it is a bug of Hudson 3.3.x. It has nothing to do with Sonar Plugin 2.0.1, which worked fine with Hudson 3.1.2.

It happens with Hudson post build action in:

A work-around is to add a build parameter to a job, see Bug 474406:

Build parameter configuration

Upvotes: 2

Related Questions