Skip to content
Permalink
Browse files
fix JENKINS-40653 CulpritsRecipientProvider does not work with pipeline
  • Loading branch information
davidvanlaatum committed Dec 23, 2016
1 parent 1ea45ba commit 60629e806a83d66a866b8985b3dbf2108642f240
@@ -55,9 +55,11 @@ public void send(final String format, final Object... args) {
if (run instanceof AbstractBuild) {
Set<User> users = ((AbstractBuild<?,?>)run).getCulprits();
RecipientProviderUtilities.addUsers(users, context.getListener(), env, to, cc, bcc, debug);
} else if (runResult != null && runResult.isWorseThan(Result.SUCCESS)) {
} else if (runResult != null) {
List<Run<?, ?>> builds = new ArrayList<>();
Run<?, ?> build = run;
builds.add(build);
build = build.getPreviousCompletedBuild();
while (build != null) {
final Result buildResult = build.getResult();
if (buildResult != null) {
@@ -44,7 +44,7 @@ public void before() throws Exception {
}

@Test
public void testAddRecipients() throws Exception {
public void testAddRecipients1() throws Exception {
final WorkflowRun build1 = PowerMockito.mock(WorkflowRun.class);
PowerMockito.when(build1.getResult()).thenReturn(Result.UNSTABLE);
MockUtilities.addChangeSet(build1, "X", "V");
@@ -66,4 +66,18 @@ public void testAddRecipients() throws Exception {

TestUtilities.checkRecipients(build4, new CulpritsRecipientProvider(), "A", "B");
}

@Test
public void testAddRecipients2() throws Exception {
final WorkflowRun build1 = PowerMockito.mock(WorkflowRun.class);
PowerMockito.when(build1.getResult()).thenReturn(Result.UNSTABLE);
MockUtilities.addChangeSet(build1, "X", "V");

final WorkflowRun build2 = PowerMockito.mock(WorkflowRun.class);
PowerMockito.when(build2.getResult()).thenReturn(Result.SUCCESS);
MockUtilities.addChangeSet(build2, "Z", "V");
PowerMockito.when(build2.getPreviousCompletedBuild()).thenReturn(build1);

TestUtilities.checkRecipients(build2, new CulpritsRecipientProvider(), "X", "V", "Z");
}
}

0 comments on commit 60629e8

Please sign in to comment.