Is there an example of JUnit Attachments Jenkins Plugin working?

一曲冷凌霜 提交于 2019-12-12 19:37:58

问题


I have been trying for the last hour or so to get the following working. I have my attachments stored in the target directory. But they are not linked on the test pages at either the class level or the test level.

I have tried every combination of the following:

  • putting the attachment folder target/surefire-reports/[class]/ with the target/surefire-reports/[class].xml folder
  • target/surefire-reports/[class.mothod]/ with the target/surefire-reports/[class].xml
  • putting the attachment folder in target/testArtifacts/[class]/ and printing [[ATTACHMENT|target/testArtifacts/[class]/captureDebug.txt]] in std out
  • putting the attachment folder in target/testArtifacts/[class]/ and printing [[ATTACHMENT|/var/lib/jenkins/.../target/testArtifacts/[class]/captureDebug.txt]] in std out

I am running with a slave master setup, not that that should matter.

My Jenkins version is 1.529 and JUnit Attachments Plugin is 1.3.

https://wiki.jenkins-ci.org/display/JENKINS/JUnit+Attachments+Plugin

I created a simple project that exemplifies this problem, you can get it here:

https://github.com/marklemay/simple-failing-project

It is build with command line maven (mvn -U -Pci clean integration-test -e).


回答1:


When I first tried to use the JUnit attachments plugin, I thought it was not working, because there seemed not to be any effect. I use Jenkins version 1.528, JUnitAttachment plugin version 1.3, Ant (not Maven) build on master (no slaves) and the approach with [[ATTACHMENT|...]] (with absolute paths) in stderr. The files where indeed copied to the build results directory in <JENKINSDIR>/jobs/<JOBNAME>/builds/<DATETIME>/junit-attachments. The attachements are only displayed on the class level. Does the junit-attachments directory appear in your build results directories?




回答2:


Your sample project worked (sort-of) for me when writing the attachment into the expected directory as seen in the diff below. I'm using Jenkins 1.540 and junit-attachments-plugin 1.3, and the project configured as a maven 2/3. I saw the attachments on the page for the test class page.

However, that "sort-of" I mentioned is because your project and attachments has the same problem I'm trying to resolve, when clicking the link for the attachment results in a 404 page.

--- a/src/test/Math/MathTest.java
+++ b/src/test/Math/MathTest.java
@@ -14,13 +14,13 @@ public class MathTest {
    public void test1p1e2() throws Exception {

            //does file writing work?
-        String relpath = "target/testArtifacts/";
+        String relpath = "target/surefire-reports/Math.MathTest/";

     (new File(relpath)).mkdirs();
     String root = relpath + this.getClass().getName();
     (new File(root)).mkdirs();

-        File path = new File(root + "/Insight.math");
+        File path = new File(root + "/test1ple2.math");
     FileUtils.write(path, "things are getting SUbtracted!!!!");



回答3:


I think the solution to this problem is upgrade to the latest version of Jenkins. My company did a blog post about how we configure the JUnit Attachments Jenkins Plugin, in case that helps anyone.



来源:https://stackoverflow.com/questions/18540263/is-there-an-example-of-junit-attachments-jenkins-plugin-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!