Skip to content
Permalink
Browse files

Fix JENKINS-27618, JENKINS-27906, JENKINS-34452, JENKINS-42967

  • Loading branch information...
slide committed Apr 7, 2017
1 parent c1b59b5 commit 5bd699cedeae13475a3321637da3d5c47397b362
164 pom.xml
@@ -1,93 +1,107 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.580.1</version>
</parent>
<version>2.19</version>
</parent>

<artifactId>nunit</artifactId>
<packaging>hpi</packaging>
<version>0.19-SNAPSHOT</version>
<name>Jenkins NUnit plugin</name>
<url>http://wiki.jenkins-ci.org/display/JENKINS/NUnit+Plugin</url>
<artifactId>nunit</artifactId>
<packaging>hpi</packaging>
<version>0.19-SNAPSHOT</version>
<name>Jenkins NUnit plugin</name>
<url>http://wiki.jenkins-ci.org/display/JENKINS/NUnit+Plugin</url>

<developers>
<developer>
<id>redsolo</id>
<name>Erik Ramfelt</name>
<email>eramfelt@gmail.com</email>
<timezone>+1</timezone>
</developer>
</developers>
<properties>
<jenkins.version>1.642.3</jenkins.version>
<java.level>7</java.level>
<maven.javadoc.skip>true</maven.javadoc.skip>
</properties>

<scm>
<connection>scm:git:ssh://github.com/jenkinsci/nunit-plugin.git</connection>
<developerConnection>scm:git:ssh://git@github.com/jenkinsci/nunit-plugin.git</developerConnection>
<url>https://svn.jenkins-ci.org/trunk/hudson/plugins/nunit/</url>
<tag>HEAD</tag>
</scm>
<developers>
<developer>
<id>redsolo</id>
<name>Erik Ramfelt</name>
<email>eramfelt@gmail.com</email>
<timezone>+1</timezone>
</developer>
<developer>
<id>slide_o_mix</id>
<name>Alex Earl</name>
<email>slide.o.mix@gmail.com</email>
<timezone>-7</timezone>
</developer>
</developers>

<distributionManagement>
<repository>
<id>maven.jenkins-ci.org</id>
<name>jenkinsci-releases</name>
<url>https://repo.jenkins-ci.org/releases/</url>
</repository>
</distributionManagement>
<scm>
<connection>scm:git:ssh://github.com/jenkinsci/nunit-plugin.git</connection>
<developerConnection>scm:git:ssh://git@github.com/jenkinsci/nunit-plugin.git</developerConnection>
<url>https://svn.jenkins-ci.org/trunk/hudson/plugins/nunit/</url>
<tag>HEAD</tag>
</scm>

<!-- see http://groups.google.com/group/hudson-dev/browse_thread/thread/83e34c639eec470a for the rationale behind this -->
<build>
<plugins>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<goals>deploy</goals>
</configuration>
</plugin>
</plugins>
</build>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<xmlOutput>true</xmlOutput>
<failOnError>false</failOnError>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>

<dependencies>
<!-- junit-plugin -->
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>junit</artifactId>
<version>1.14</version>
<version>1.20</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.2</version>
</dependency>

<!-- testing -->
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock-junit4</artifactId>
<version>2.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock-legacy</artifactId>
<version>2.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.5</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>hamcrest-core</artifactId>
<groupId>org.hamcrest</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-war</artifactId>
<type>war</type>
<version>${jenkins.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<repositories>
<repository>
@@ -8,6 +8,7 @@
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;

import jenkins.security.MasterToSlaveCallable;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.types.FileSet;
import org.jenkinsci.remoting.RoleChecker;
@@ -26,44 +27,40 @@
*
* @author Erik Ramfelt
*/
public class NUnitArchiver implements FilePath.FileCallable<Boolean>, Serializable {
public class NUnitArchiver extends MasterToSlaveCallable<Boolean, IOException> {

private static final long serialVersionUID = 1L;

public static final String JUNIT_REPORTS_PATH = "temporary-junit-reports";

// Build related objects
private final String root;
private final TaskListener listener;
private final String testResultsPattern;
private final TestReportTransformer unitReportTransformer;
private final boolean failIfNoResults;

private TestReportTransformer unitReportTransformer;

private final Boolean failIfNoResults;
private int fileCount;

@Deprecated
public NUnitArchiver(BuildListener listener, String testResults, TestReportTransformer unitReportTransformer) throws TransformerException {
this(listener, testResults, unitReportTransformer, true);
}

public NUnitArchiver(TaskListener listener, String testResults, TestReportTransformer unitReportTransformer, Boolean failIfNoResults) throws TransformerException {
public NUnitArchiver(String root, TaskListener listener, String testResultsPatter, TestReportTransformer unitReportTransformer, boolean failIfNoResults) {
this.root = root;
this.listener = listener;
this.testResultsPattern = testResults;
this.testResultsPattern = testResultsPatter;
this.unitReportTransformer = unitReportTransformer;
this.failIfNoResults = failIfNoResults;
}

/** {@inheritDoc} */
public Boolean invoke(File ws, VirtualChannel channel) throws IOException {
Boolean retValue = Boolean.TRUE;
String[] nunitFiles = findNUnitReports(ws);
public Boolean call() throws IOException {
boolean retValue = true;
String[] nunitFiles = findNUnitReports(new File(root));
if (nunitFiles.length > 0) {
File junitOutputPath = new File(ws, JUNIT_REPORTS_PATH);
File junitOutputPath = new File(root, JUNIT_REPORTS_PATH);
junitOutputPath.mkdirs();

for (String nunitFileName : nunitFiles) {
FileInputStream fileStream = new FileInputStream(new File(ws, nunitFileName));
try {
try(FileInputStream fileStream = new FileInputStream(new File(root, nunitFileName))) {
unitReportTransformer.transform(fileStream, junitOutputPath);
fileCount++;
} catch (TransformerException te) {
throw new IOException(
"Could not transform the NUnit report. Please report this issue to the plugin author", te);
@@ -72,26 +69,28 @@ public Boolean invoke(File ws, VirtualChannel channel) throws IOException {
"Could not transform the NUnit report. Please report this issue to the plugin author", se);
} catch (ParserConfigurationException pce) {
throw new IOException(
"Could not initalize the XML parser. Please report this issue to the plugin author", pce);
} finally {
fileStream.close();
"Could not initialize the XML parser. Please report this issue to the plugin author", pce);
}
}
} else if(this.failIfNoResults) {
retValue = Boolean.FALSE;
retValue = false;
}

return retValue;
}

int getFileCount() {
return fileCount;
}

/**
* Return all NUnit report files
*
* @param parentPath parent
* @return an array of strings
*/
private String[] findNUnitReports(File parentPath) {
FileSet fs = Util.createFileSet(parentPath,testResultsPattern);
FileSet fs = Util.createFileSet(parentPath, testResultsPattern);
DirectoryScanner ds = fs.getDirectoryScanner();

String[] nunitFiles = ds.getIncludedFiles();

0 comments on commit 5bd699c

Please sign in to comment.
You can’t perform that action at this time.