Skip to content

Commit

Permalink
Add build status to activityTitle
Browse files Browse the repository at this point in the history
Ensure that the most important information (job name and build status) appears
above the fold in Teams notification. Fixes #264.
  • Loading branch information
PeteAudinate committed Jan 8, 2024
1 parent a27576b commit e8114e7
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Card createStartedCard(List<FactDefinition> factDefinitions) {
factsBuilder.addDevelopers();
factsBuilder.addUserFacts(factDefinitions);

Section section = buildSection();
Section section = buildSection(statusName);

String summary = getDisplayName() + ": Build " + getRunName();
Card card = new Card(summary, section);
Expand Down Expand Up @@ -84,7 +84,7 @@ public Card createCompletedCard(List<FactDefinition> factDefinitions) {
factsBuilder.addDevelopers();
factsBuilder.addUserFacts(factDefinitions);

Section section = buildSection();
Section section = buildSection(status);

Card card = new Card(summary, section);
card.setThemeColor(getCardThemeColor(lastResult));
Expand All @@ -104,8 +104,8 @@ private static String getCardThemeColor(Result result) {
}
}

private Section buildSection() {
String activityTitle = "Notification from " + getEscapedDisplayName();
private Section buildSection(String status) {
String activityTitle = "Notification from " + getEscapedDisplayName() + ": " + status;
String activitySubtitle = "Latest status of build " + getRunName();
return new Section(activityTitle, activitySubtitle, factsBuilder.collect());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void createStartedCard_ReturnsCard() {
assertThat(card.getSections()).hasSize(1);
assertThat(card.getThemeColor()).isEqualTo("3479BF");
Section section = card.getSections().get(0);
assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME);
assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME + ": Started");
}

@Test
Expand All @@ -81,7 +81,7 @@ public void createCompletedCard_OnAborted_ReturnsCard() {
assertThat(card.getSections()).hasSize(1);
assertThat(card.getThemeColor()).isEqualTo(result.color.getHtmlBaseColor());
Section section = card.getSections().get(0);
assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME);
assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME + ": Build Aborted");
}

@Test
Expand All @@ -98,7 +98,7 @@ public void createCompletedCard_OnFirstFailure_ReturnsCard() {
assertThat(card.getSections()).hasSize(1);
assertThat(card.getThemeColor()).isEqualTo(result.color.getHtmlBaseColor());
Section section = card.getSections().get(0);
assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME);
assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME + ": Build Failed");
}

@Test
Expand All @@ -125,7 +125,7 @@ public void createCompletedCard_OnSecondFailure_AddsFailingSinceFact() {
assertThat(card.getSections()).hasSize(1);
assertThat(card.getThemeColor()).isEqualTo(result.color.getHtmlBaseColor());
Section section = card.getSections().get(0);
assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME);
assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME + ": Repeated Failure");
FactAssertion.assertThatLast(section.getFacts(), 2)
.hasName(FactsBuilder.NAME_FAILING_SINCE_BUILD)
.hasValue("build #" + previousNotFailedBuildNumber);
Expand Down Expand Up @@ -155,7 +155,7 @@ public void createCompletedCard_OnFirstFailure_SkipsFailingSinceFact() {
assertThat(card.getSections()).hasSize(1);
assertThat(card.getThemeColor()).isEqualTo(result.color.getHtmlBaseColor());
Section section = card.getSections().get(0);
assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME);
assertThat(section.getActivityTitle()).isEqualTo("Notification from " + JOB_DISPLAY_NAME + ": Build Failed");
FactAssertion.assertThatLast(section.getFacts(), 1);
FactAssertion.assertThat(section.getFacts())
.hasName(FactsBuilder.NAME_STATUS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"value": "damian"
}
],
"activityTitle": "Notification from hook » PR\\-1",
"activityTitle": "Notification from hook » PR\\-1: Back to Normal",
"activitySubtitle": "Latest status of build #3"
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/requests/completed-failed.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"value": "Mike"
}
],
"activityTitle": "Notification from myFirst\\_Job\\_",
"activityTitle": "Notification from myFirst\\_Job\\_: Build Failed",
"activitySubtitle": "Latest status of build #167"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"value": "Mike"
}
],
"activityTitle": "Notification from myFirst\\_Job\\_",
"activityTitle": "Notification from myFirst\\_Job\\_: Repeated Failure",
"activitySubtitle": "Latest status of build #167"
}
],
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/requests/completed-success.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"value": "Mike"
}
],
"activityTitle": "Notification from myFirst\\_Job\\_",
"activityTitle": "Notification from myFirst\\_Job\\_: Build Success",
"activitySubtitle": "Latest status of build #167"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"value": "damianszczepanik (Damian Szczepanik)"
}
],
"activityTitle": "Notification from hook » PR\\-1",
"activityTitle": "Notification from hook » PR\\-1: Repeated Failure",
"activitySubtitle": "Latest status of build #3"
}
],
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/requests/started-developers.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"value": "Ann, the Queen, George Great, Peter"
}
],
"activityTitle": "Notification from simple job",
"activityTitle": "Notification from simple job: Started",
"activitySubtitle": "Latest status of build #1"
}
],
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/requests/started.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"value": "Mike"
}
],
"activityTitle": "Notification from myFirst\\_Job\\_",
"activityTitle": "Notification from myFirst\\_Job\\_: Started",
"activitySubtitle": "Latest status of build #167"
}
],
Expand Down

0 comments on commit e8114e7

Please sign in to comment.