Skip to content
Permalink
Browse files
[FIXED JENKINS-39537] Fixed ClaimTestDataPublisher not working with J…
…enkins 2.0 pipelines (kept hanging while publishing JUnit results).
  • Loading branch information
rkettelerij committed Nov 7, 2016
1 parent 99963f0 commit 020aa5d5d588cf4dc922bb3dd687b32bcb63d8ed
Showing with 38 additions and 18 deletions.
  1. +8 −2 pom.xml
  2. +9 −5 src/main/java/hudson/plugins/claim/ClaimTestAction.java
  3. +21 −11 src/main/java/hudson/plugins/claim/ClaimTestDataPublisher.java
10 pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.596.1</version>
<version>2.6</version>
</parent>

<artifactId>claim</artifactId>
@@ -18,6 +18,12 @@
<developerConnection>scm:git:git@github.com:jenkinsci/claim-plugin.git</developerConnection>
<tag>claim-2.4</tag>
</scm>

<properties>
<!--<jenkins.version>1.596.1</jenkins.version>-->
<jenkins.version>2.19.1</jenkins.version>
</properties>

<build>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
@@ -55,7 +61,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>junit</artifactId>
<version>1.5</version>
<version>1.19</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
@@ -1,13 +1,17 @@
package hudson.plugins.claim;

import hudson.model.Run;
import hudson.plugins.claim.ClaimTestDataPublisher.Data;

public class ClaimTestAction extends AbstractClaimBuildAction<Data> {
public class ClaimTestAction extends AbstractClaimBuildAction<Run> {

private String testObjectId;

ClaimTestAction(Data owner, String testObjectId) {
super(owner);
private Data data;

ClaimTestAction(Data data, String testObjectId) {
super(data.getBuild());
this.data = data;
this.testObjectId = testObjectId;
}

@@ -18,7 +22,7 @@ public String getDisplayName() {
@Override
public void claim(String claimedBy, String reason, String assignedBy, boolean sticky) {
super.claim(claimedBy, reason, assignedBy, sticky);
owner.addClaim(testObjectId, this);
data.addClaim(testObjectId, this);
}

@Override
@@ -28,7 +32,7 @@ public String getNoun() {

@Override
String getUrl() {
return owner.getURL();
return data.getURL();
}

}
@@ -1,11 +1,9 @@
package hudson.plugins.claim;

import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.Descriptor;
import hudson.model.Saveable;
import hudson.model.*;
import hudson.tasks.junit.CaseResult;
import hudson.tasks.junit.TestAction;
import hudson.tasks.junit.TestDataPublisher;
@@ -27,10 +25,9 @@
public ClaimTestDataPublisher() {}

@Override
public Data getTestData(AbstractBuild<?, ?> build, Launcher launcher,
BuildListener listener, TestResult testResult) {

Data data = new Data(build);
public Data contributeTestData(Run<?, ?> run, FilePath workspace, Launcher launcher,
TaskListener listener, TestResult testResult) throws IOException, InterruptedException {
Data data = new Data(run);

for (CaseResult result: testResult.getFailedTests()) {
CaseResult previous = result.getPreviousResult();
@@ -43,25 +40,38 @@ public Data getTestData(AbstractBuild<?, ?> build, Launcher launcher,
}
}
}

return data;
}

@Override
public Data getTestData(AbstractBuild<?, ?> build, Launcher launcher,
BuildListener listener, TestResult testResult) {
try {
return contributeTestData(build, null, launcher, null, testResult);
} catch (IOException | InterruptedException e) {
throw new IllegalStateException(e);
}
}

public static class Data extends TestResultAction.Data implements Saveable {

private Map<String,ClaimTestAction> claims = new HashMap<String,ClaimTestAction>();

private final AbstractBuild<?,?> build;

public Data(AbstractBuild<?,?> build) {
private final Run<?,?> build;

public Data(Run<?,?> build) {
this.build = build;
}

public String getURL() {
return build.getUrl();
}

public Run<?, ?> getBuild() {
return build;
}

@Override
public List<TestAction> getTestAction(TestObject testObject) {
String id = testObject.getId();

0 comments on commit 020aa5d

Please sign in to comment.