project module are getting skipped in night build configuration - maven

Kindly note: "I have edited this question"
I am observing a very strange situation. I have 2 jobs configured in Jenkins having same configuration except that one of them is continuous build and another is nightly build [ poll scm configured #midnight] with Sonarqube configuration to generate report.
Both builds have same Repository URL and Both of them are having build result success. But in continuous build, every modules is analysed and then getting success. whereas in nightly build, modules are skipped.
what my question is same build is running fine for continuous build and not for nightly. so what could be cause of this ?
Earlier i was using -DskipTests which was analysing all module and getting successful in continuous build.. but was skipping in nightly build.
so i refered this link Maven skip tests and added -Dmaven.test.skip=true in maven goals.. and now some of the modules are analysed and getting success. But one fo the module got failed and due to which other modules got skipped. below is the error log
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test
(default-test) on project ASData: There are test failures.
Note: I am using maven 3.3.1 version and SonarQube 5.1

I am still not allowed to add comments so I will ask here.
Where do you keep the modules and can you guarantee that noone will severe the connection between your build and the storage of modules?

Related

Maven Build gets Failed saying Could not assemble p2 repository: Mirroring failed: No repository found at

I have a maven build for building an eclipse plugin which gets hung sporadically during the execution of
--- tycho-p2-repository-plugin:1.1.0:assemble-repository (default-assemble-repository) # com.sample.product ---
Otherwise the build will get failed saying the following error.
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-p2-repository-plugin:1.1.0:assemble-repository (default-assemble-repository) on project p2:Could not assemble p2 repository: Mirroring failed: No repository found at file:/C:/Users/obuli/.m2/repository/.
I am using the following maven goals and options
clean deploy -Dtycho.localArtifacts=ignore
I have searched for this issue and landed on this Bug , It says there was a bug in tycho 0.26.0 But I am currently using Tycho version 1.1.0
Since the issue is very sporadic I could not able to identify the root cause. Please let me what I am missing here.
I intermittently had this problem as well. After running mvn clean and mvn deploy separately once, mvn clean deploy started working as well.
Now I don't seem to be able to recreate the original issue, even using git clean -xfd and deleting all snapshots from the local and remote repository.
I can only guess that there were some leftover files from earlier builds which were not cleaned by mvn clean deploy but by mvn clean, and these leftover files must have broken the build.

maven package: skip successfully built sub-modules

I'm trying to build a multi sub-modules project using maven 3.3.9 with --fail-at-end. Running one cycle of this phase took so much time (some hours) and in every cycle i solve problems in building some of sub-modules and running maven build again (starting another cycle).
So the question is: Is there any way to force maven not to try building packages which been built successfully in previous cycles?
Thanks in advance
It sounds like you have a multi module project and you are trying to get a complete, successful build via an iterative process of ...
build -> fail -> fix the failure -> rebuild
... and each time around that loop you'd like to resume with the module in which the failure occurred rather than building the whole project every time.
The standard approach to this use case is to use -rf:
-rf, --resume-from
Resume reactor from specified project
For example, if the module named moduleD fails then re-run your build as follows:
mvn -rf :moduleD install
More details in the docs.
You might also choose not to include the clean phase when re-running your build, thereby allowing Maven's incremental compiler to work out what needs to be rebuilt.

-Dmaven.test.failure.ignore=true set, but build still errors on test failure

I have two different freestyle Jenkins jobs that are kicked off like this (build commands lifted from the job logs):
mvn -Dcloudbees.private.release.repository.off=true -Dcloudbees.private.snapshot.plugin.repository.off=true -Dcloudbees.private.release.plugin.repository.off=true -Dcloudbees.central.repository.off=true -Dcloudbees.private.snapshot.repository.off=true clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Dmaven.test.failure.ignore=true -V -Dcheckstyle.skip=true -Dpmd.skip=true -Dgpg.skip=true -B -e
and
mvn clean install cobertura:cobertura -DallTests -Dcobertura.report.format=xml -Dmaven.test.failure.ignore=true -V -Dcheckstyle.skip=true -Dpmd.skip=true
They end like this (respectively):
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project gora-core: There are test failures.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project wildfly-domain-management: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test failed:
All my searching tells me that -Dmaven.test.failure.ignore=true should do the trick, so I'm stymied.
Note that I don't have write access to these projects; I'm simply trying to compile in preparation for SonarQube analysis.
UPDATE1
I turned out to have 3 jobs (and counting) with these symptoms. For the record, they are:
ActiveMQ (not previously listed)
Wildfly Core
Gora
The addition of -B to the ActiveMQ job (the others already had it) moved it forward to the point of an actual compile failure. Unfortunately, the job still hasn't succeeded, so I can't be sure that -B actually fixed the job.
I tried Gora locally with the same result as on Jenkins.
UPDATE2
I've since found <testFailureIgnore>false</testFailureIgnore> in the main Gora pom, but grep tells me testFailureIgnore is nowhere in the Wildfly Core project.
UPDATE3
The Wildfly Core failure can apparently be chalked up to a bug in Surefire 2.17
Try running Maven in debug mode (-X) to see what Maven thinks that property is before it starts actually running the tests. If someone or something has hardcoded the value in the POM (e.g. <testFailureIgnore>false</testFailureIgnore>) then it could be ignoring the command line value you're providing.
Also make sure the Jenkins job is not a Maven job type. Stephen Connolly wrote a blog post about why the Jenkins Maven job type is evil and he explicitly mentioned that the test ignore toggle is one item modified by the plugin under the covers. One of the comments on that post is:
sorry testFailureIgnore is false not skip is true..., e.g.
<configuration>
<testFailureIgnore>false</testFailureIgnore>
<configuration>
which will ensure that the module's tests cannot be skipped... except when the Maven job type is playing fast and loose with its auto-magic

Maven reactor and site

I have a multi-module project with a parent pom.xml and several modules where some of the modules depend on each other. In the project directory I can call
mvn test
to run unittests in each module. No problem here. But if I call
mvn site
one of the modules reports
[ERROR] Failed to execute goal on project myModule_C: Could not resolve dependencies
for project org.myModule_C:jar:0.0.1-SNAPSHOT: The following artifacts could not be
resolved: org.myModule_A:jar:0.0.1-SNAPSHOT, org.myModule_B:jar:0.0.1-SNAPSHOT: Failure
to find org.myModule_A:jar:0.0.1-SNAPSHOT in http://artifactory-server:8081/artifactory/repo
was cached in the local repository, resolution will not be reattempted until the update
interval of server has elapsed or updates are forced -> [Help 1]
I think this should not happen since these dependencies are found during "mvn test". Also, they are not in the artifactory-server but part of the parent project. The goal that is mentioned in the ERROR is the goal site. Why does the mvn test succeed (with respect to dependencies it finds) and mvn site does not? Do I have to build the site in a special way - because this is a reactor build?
You should execute the mvn install as least once. Please see further information at the Maven Build Life Cycle and Maven in 5 Minutes.
Here is the overview
Maven Phases
Although hardly a comprehensive list, these are the most common default lifecycle phases executed.
validate: validate the project is correct and all necessary information is available
compile: compile the source code of the project
test: test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
package: take the compiled code and package it in its distributable format, such as a JAR.
integration-test: process and deploy the package if necessary into an environment where integration tests can be run
verify: run any checks to verify the package is valid and meets quality criteria
install: install the package into the local repository, for use as a dependency in other projects locally
deploy: done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.
There are two other Maven lifecycles of note beyond the default list above
They are:
clean: cleans up artifacts created by prior builds
site: generates site documentation for this project
I hope this may help.

Sonar not picking up clover test results created by running maven in jenkins

I've been working on this all day and haven't been able to find a solution, so thought i'd turn to the stackoverflow community.
I have a server setup with Jenkins (version 1.454). It's configured to perform the build with Maven (version 3.0.4). The build command is as follows:
clean clover2:setup verify clover2:aggregate clover2:clover
Jenkins has the sonar plugin installed and configured. My sonar install (version 3) is on a different server to jenkins. After the build is completed, i can see the results on sonar (the basics of the build).
I have installed to sonar the clover plugin (sonar-clover-plugin-2.8.jar) manually by putting it into the 'extentions/plugins' folder. It appeared in sonar and I can configure it. I put in the license, version (3.1.4) and sonar.clover.reportPath as "target\site\clover\clover.xml".
When I run the build, it is successful as before, and I can see the basic results as before in Sonar, however, I cannot see any test code coverage results.
When I look at the maven build output I notice the following:
[INFO] Writing report to '/opt/jenkins/jobs/foo/workspace/target/site/clover/clover.xml'
and then near the bottom of the output:
[INFO] [15:08:36.586] Clover XML report not found
The following are also in my pom:
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.clover.reportPath>target\site\clover\clover.xml</sonar.clover.reportPath>
<sonar.surefire.reportsPath>target\surefire-reports</sonar.surefire.reportsPath>
<sonar.core.codeCoveragePlugin>clover</sonar.core.codeCoveragePlugin>
<sonar.clover.version>${clover.version}</sonar.clover.version>
When I look on the jenkins box, I can see that it has generated the clover.xml file (infact in my fiddling I have the clover plugin working on jenkins, so i can see the results there!).
I'm guessing at this stage that there is some issue with jenkins and sonar being on seperate boxes.
Any help would be appreciated!
Cheers.
After a lot more fiddling around, it appeared that I needed to change the following:
<sonar.clover.reportPath>${project.build.directory}/site/clover/clover.xml</sonar.clover.reportPath>
<sonar.surefire.reportsPath>${project.build.directory}/surefire-reports</sonar.surefire.reportsPath>
A good reference was the following:
all about pom variables

Resources