Reputation: 325
I'm using pytest to run pep8 check (all of the listed below is happening on a windows machine):
py.test --pep8 --junitxml=reports\pep8.log
I setup a job to look for pep8.log file in reports\pep8.log
But when i run the job I see that the path where violations plugin looks for reports makes no sense:
generated xml file: C:\Jenkins\jobs\python-template-2\workspace\reports\pep8.log =============== 89 failed, 33 skipped, 1 error in 1.48 seconds ================
C:\Jenkins\jobs\python-template-2\workspace>exit 1 Build step 'Выполнить команду Windows' marked build as failure ERROR: Publisher hudson.plugins.violations.ViolationsPublisher aborted due to exception java.io.FileNotFoundException: C:\Jenkins\jobs\python-template-2\builds\2013-10-22_13-30-44\violations\file\<\failure><\testcase>C:\Jenkins\jobs\python-template-2\workspace\contests\migrations\0003_auto__add_votinghistory.py.xml (Syntax error in filename) at java.io.FileOutputStream.open(Native Method) at java.io.FileOutputStream.(Unknown Source) at java.io.FileOutputStream.(Unknown Source) at hudson.FilePath.write(FilePath.java:1642) at hudson.plugins.violations.generate.ExecuteFilePath.execute(ExecuteFilePath.java:40) at hudson.plugins.violations.generate.GenerateXML.execute(GenerateXML.java:47) at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:122) at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:25) at hudson.FilePath.act(FilePath.java:912) at hudson.FilePath.act(FilePath.java:885) at hudson.plugins.violations.ViolationsPublisher.perform(ViolationsPublisher.java:74) at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:781) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:753) at hudson.model.Build$BuildExecution.post2(Build.java:183) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:706) at hudson.model.Run.execute(Run.java:1690) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:230) Finished: FAILURE
Addittionally, I tried to launch pep8 check without using pytest, instead I used this command for windows to find and check all .py files:
FOR /R %i IN (*.py) DO pep8 %i 1>>reports\pep8.log
In this case, I get the following:
C:\Jenkins\jobs\python-template-2\workspace>exit 1 Build step 'Выполнить команду Windows' marked build as failure ERROR: Publisher hudson.plugins.violations.ViolationsPublisher aborted due to exception java.io.FileNotFoundException: C:\Jenkins\jobs\python-template-2\builds\2013-10-15_13-31-37\violations\file\C:\Jenkins\jobs\python-template-2\workspace\notifications\email.py.xml (Syntax error in filename) at java.io.FileOutputStream.open(Native Method) at java.io.FileOutputStream.(Unknown Source) at java.io.FileOutputStream.(Unknown Source) at hudson.FilePath.write(FilePath.java:1666) at hudson.plugins.violations.generate.ExecuteFilePath.execute(ExecuteFilePath.java:40) at hudson.plugins.violations.generate.GenerateXML.execute(GenerateXML.java:47) at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:122) at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:25) at hudson.FilePath.act(FilePath.java:916) at hudson.FilePath.act(FilePath.java:889) at hudson.plugins.violations.ViolationsPublisher.perform(ViolationsPublisher.java:74) at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:786) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:758) at hudson.model.Build$BuildExecution.post2(Build.java:183) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:711) at hudson.model.Run.execute(Run.java:1690) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:246) Finished: FAILURE
Upvotes: 0
Views: 1116
Reputation: 1073
I encountered a similar error when using pylint with Jenkins. This seems to occur in a windows environment, and is an issue with how the Violations plugin builds the paths. If you notice in your error, it's attempting to add the full path of the file you tested to your current directory (which is C:\Jenkins\jobs\python-template-2\builds\2013-10-22_13-30-44\violations\file\<\failure>\<\testcase>
).
To fix this problem when it occurred for me, I wrote a small script and ran it after the tests. It removed most of the path, and just left the part that could be added to the base path without causing file not found errors. Here is the script:
with open('.\pylint_report.xml', 'r') as lint_file:
out = ''.join([line.replace('E:\\Jenkins\workspace\\', '')
for line in lint_file.readlines()])
with open('.\pylint_report.xml', 'w') as lint_file:
lint_file.write(out)
You should be able to adapt this to your specific use case.
Upvotes: 1