Identifying CheckStyle Errors via Maven CLI - checkstyle

I build my projects via mvn on the command line.
Whenever a checkStyle error occurs, I see this type of output:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-
plugin:2.4:checkstyle (default) on project myProject-server:
An error has occurred in Checkstyle report generation.
There are 2 checkstyle errors. -> [Help 1]
How do I find out which code lines are causing these CheckStyle failures?

CheckStyle saves reports to target/checkstyle-result.xml (for non-modular project). So you may find out this file and examine it.
Another case is to configure maven-checkstyle-plugin to show all such warnings/error to console:
<consoleOutput>true</consoleOutput>

Related

Checkstyle Can't Generate Report With Custom Check

I am trying to create my own custom check for Checkstyle. I created an artifact and gave it on the classpath (dependency in the POM). Then included it in my configuration.xml file. I am getting the following error:
An error has occurred in Checkstyle report generation.: Failed during checkstyle configuration: cannot initialize module TreeWalker - Unable to instantiate 'com.lft.cos.checkstyle.custom.MethodsOrderCheck' class.
Can someone point me to what I am doing wrong?

unable to compile apache drill code

I cloned the drill git repository and when I run
mvn clean package -DskipTests
I get this error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (validate_java_and_maven_version) on project drill-root: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
You need to use JDK 1.7 to build Apache Drill.
The Drill team added maven-enforcer-plugin to the build process to make sure that build gives an error if someone tries to build using an unsupported version of Java or Maven. If you scroll up you will see an earlier error message like the following:
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (validate_java_and_maven_version) # drill-root ---
[WARNING] Rule 1: org.apache.maven.plugins.enforcer.RequireJavaVersion failed with message:
Detected JDK Version: 1.8.0-51 is not in the allowed range [1.7,1.8).
A lot of people want to run Drill using JDK 1.8. There's good news on that front. While you can't build using JDK 1.8, once you've built, you can run Drill with JDK 1.8 just fine.

Why isn't findbugs_result.xml generated?

I installed jenkins 1.452 and findbugs 4.34, when after building and invoking findbugs, findbugs_result.xml isn't generate so findbugs report isn't generated neither. Below message is out:
[FINDBUGS] Collecting findbugs analysis files...
Finished: SUCCESS
Normaly findbugs is supposed to generate result.xml and parse it out to many warnings so that we could see many warning or progress message in the output console. Findbugs work normally for the same project in hudson, and I cofigure in jenkins the same as in hudson. Below is configuration snapshot.
OS is CentOS, and where I can find findbugs log ,I think maybe some erros are out, log will be very helpful to my case.
I change name to '**/findbugs.xml", it throws another error:
[FINDBUGS] Collecting findbugs analysis files...
[FINDBUGS] Parsing 1 files in /home/irteam/.jenkins/jobs/hangame-dnest/workspace
[FINDBUGS] Parsing of file /home/irteam/.jenkins/jobs/hangame-dnest/workspace/common-build/common/findbugs.xml failed due to an exception:
org.dom4j.DocumentException: Sax error Nested exception: Invalid top-level element (expected BugCollection, saw project)
Do you have some clues?

Hudson | NullPointerException while loading jobs

We are using hudson version 2.0.0.
Few days back after restarting hudson, i found that some of the jobs were missing.
Found that its due to the following NPE.
Dec 9, 2011 11:39:34 AM hudson.model.Hudson$5 onTaskFailed
SEVERE: Failed Loading job ABC
java.lang.NullPointerException
at hudson.model.Project.createTransientActions(Project.java:206)
at hudson.model.AbstractProject.updateTransientActions(AbstractProject.java:627)
at hudson.model.AbstractProject.onLoad(AbstractProject.java:287)
at hudson.model.Project.onLoad(Project.java:87)
at hudson.model.Items.load(Items.java:109)
at hudson.model.Hudson$13.run(Hudson.java:2376)
at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:146
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:259)
at hudson.model.Hudson$4.runTask(Hudson.java:707)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:187)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:94)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTaskThreadPoolExecutor.java
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Upgrading to 2.1.2 didnt help. I removed all the plugins and re-installed, but in vain.
Has anybody else faced this?
Thanks,
Gayathri
OK I found the problem.
To fix this issue, I had to add the line that contains <publishers/> to each config.xml file in projects that failed to load (towards the end of XML file):
</builders>
<buildWrappers/>
<publishers/>
</project>
Somehow without this, Hudson/Jenkins barfs and hides in the corner crying.
Jobs will go missing from the dashboard when there is a parse error in the config.xml.
You can inspect these errors in Hudson / Manage Hudson / System Log looking for
Caused by: com.thoughtworks.xstream.converters.ConversionException: Could not call hudson.scm.CVSSCM.readResolve() : null :
It means the auto parameter migration failed and you have to edit the config.xml in the Jobs root by hand, the debug information in the log provides the offending line number. Commenting out the item usually works. Sometimes manual reconfiguring is needed.
Jobs will go missing from the history between restarts when the file build.xml is not generated in the build/<jobref> directory. If there is an exception in any plugin, it may cause the creation of this file to be skipped, and it will not show in history after a restart. Again looking in the log using Hudson / Manage Hudson / System Log is the quickest way to find the offending plugin. Disabling usually resolves the problem.
Please note that searching for "Missing Hudson Builds" will point to many different plugins/versions that all cause this problem. You should look in YOUR log to find what is causing the problem in YOUR installation, and only disabling the plugin that is causing YOUR problem.
A warning about "failed to generate build.xml" would save a lot of hours. I should open a bug on that.

How do I configure CI hudson with PHPunit and how do I run phpunit using hudson?

I am getting following error mentioned below. Help is much needed for this...
kindly go through the errors.
Started by an SCM change
Updating https://suppliesguys.unfuddle.com/svn/suppliesguys_frontend2/Frontend-Texity/src
U sites\all\modules\print\print_pdf\print_pdf.pages.inc
At revision 1134
[workspace] $ sh -xe C:\WINDOWS\TEMP\hudson6292587174545072503.sh
The system cannot find the file specified
FATAL: command execution failed
java.io.IOException: Cannot run program "sh" (in directory "E:\Projects\Hudson\.hudson\jobs\TSG\workspace"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:149)
at hudson.Proc$LocalProc.<init>(Proc.java:121)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:636)
at hudson.Launcher$ProcStarter.start(Launcher.java:271)
at hudson.Launcher$ProcStarter.join(Launcher.java:278)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:83)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:58)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:584)
at hudson.model.Build$RunnerImpl.build(Build.java:174)
at hudson.model.Build$RunnerImpl.doRun(Build.java:138)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:416)
at hudson.model.Run.run(Run.java:1244)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:122)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 17 more
Publishing Javadoc
Publishing Clover coverage report...
No Clover report will be published due to a Build Failure
[xUnit] Starting to record.
[xUnit] [PHPUnit] - Use the embedded style sheet.
[xUnit] [ERROR] - No test report file(s) were found with the pattern 'build/logs/phpunit.xml' relative to 'E:\Projects\Hudson\.hudson\jobs\TSG\workspace' for the testing framework 'PHPUnit'. Did you enter a pattern relative to the correct directory? Did you generate the result report(s) for 'PHPUnit'?
[xUnit] Stopping recording.
Finished: FAILURE
It looks like you are using the "Execute shell" build step on a windows system instead of the "Execute Windows batch command" build step. Windows doesn't normally have 'sh', so the former won't work.
Looks like you have a couple of problems:
FATAL: command execution failed java.io.IOException: Cannot run program "sh" (in directory "E:\Projects\Hudson.hudson\jobs\TSG\workspace"):
The user that's running the Hudson job doesn't have the "sh" command in its path, so it can't run shell scripts. Adding /bin to the $PATH of the Hudson user should fix this.
[xUnit] [ERROR] - No test report file(s) were found with the pattern 'build/logs/phpunit.xml' relative to 'E:\Projects\Hudson.hudson\jobs\TSG\workspace' for the testing framework 'PHPUnit'.
This is probably a result of the previous error; the build just didn't get far enough to run the PHPUnit tests.
'sh' is for linux implementations. Both '.exe' and 'bat' files are used in windows. Are you trying to setup and run Hudson on windows or linux?