Skip to content

Commit

Permalink
fix JENKINS-40653 CulpritsRecipientProvider does not work with pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
davidvanlaatum committed Dec 23, 2016
1 parent 1ea45ba commit 60629e8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Expand Up @@ -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) {
Expand Down
Expand Up @@ -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");
Expand All @@ -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.